- Home /
NullReferenceException in UnityEditor.InspectorWindow.GetEditorsWithPreviews (UnityEditor.Editor[] editors)
I made a CustomEditor that displays a button in the inspector that allows to open another scene. If I click that button it does open the correct scene, but the console reports a NullReferenceException with the following stack trace:
NullReferenceException: Object reference not set to an instance of an object UnityEditor.InspectorWindow.GetEditorsWithPreviews (UnityEditor.Editor[] editors) UnityEditor.InspectorWindow.DrawPreviewAndLabels () UnityEditor.InspectorWindow.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
I expect this is because I am triggering the scene load from inside the OnInspectorGUI function. I tried delaying the call to the end of OnInspectorGUI, but that doesn't fix my problem. What I probably need to do is call the function outside of any gui function. Is there a way to do that with the Button still being shown in the inspector?
Hi! I'm having the same problem as you. Did you ever get around this?
Same problem, same thoughts. Haven't figured this out yet. Also had a weird error when using BuildPipeline.BuildPlayer() from an EditorWindow's OnGUI() method, don't know if it is related.