Quantcast
Channel: Questions in topic: "exception"
Viewing all articles
Browse latest Browse all 470

Inspector removing MeshRenderer generates error

$
0
0
If you create a custom inspector with a button that tries to removes/destroy the MeshRenderer component an exception is generated in editor/engine code that I cannot prevent. MeshRenderer mr = obj.GetComponent(); if (mr != null) { DestroyImmediate(mr); } It does appear to destroy the component and then no longer complain -- but I'd prefer to write code that generates no false exceptions. Is there a way to fix this? Paul MissingReferenceException: The object of type 'MeshRenderer' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEditor.Editor.IsEnabled () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:589) UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1151) UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1028) UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:352) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Viewing all articles
Browse latest Browse all 470

Trending Articles