Search Issue Tracker

Fixed in 2022.2.X

Votes

0

Found in

2020.3

2021.2

2022.1

Issue ID

1366567

Regression

No

EditorWindow fails to open when the cause of NullReferenceException in CreateGUI() is fixed

IMGUI

-

How to reproduce:
1. Open the attached project ("1366567_repro.zip")
2. Open the "ExampleWindow.cs" script
3. Uncomment lines 36, 37 and save
4. Open ExampleWindow (Window -> UI Toolkit -> ExampleWindow)
5. Comment-out lines 36, 37 and save
6. Open ExampleWindow again

Expected result: "ExampleWindow" EditorWindow opens
Actual result: "ExampleWindow" EditorWindow does not open

Reproducible with: 2020.3.22f1, 2021.2.2f1, 2022.1.0a13
Could not test with: 2019.4.32f1 (UI Toolkit not available)

Note:
- Reproducible on macOS and Windows

NullReferenceException:
Object reference not set to an instance of an object
ExampleWindow.CreateGUI () (at Assets/ExampleWindow.cs:25)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b41efef47d3b4ee7904c28860bf6ccb8>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b41efef47d3b4ee7904c28860bf6ccb8>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <b41efef47d3b4ee7904c28860bf6ccb8>:0)
UnityEditor.UIElements.DefaultEditorWindowBackend.Invoke (System.String methodName) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/WindowBackends/DefaultEditorWindowBackend.cs:354)
UnityEditor.UIElements.DefaultEditorWindowBackend.SendInitializeIfNecessary (System.Boolean duringOnCreate) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/WindowBackends/DefaultEditorWindowBackend.cs:347)
UnityEditor.UIElements.DefaultEditorWindowBackend.RegisterWindow (System.Boolean duringOnCreate) (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/WindowBackends/DefaultEditorWindowBackend.cs:137)
UnityEditor.UIElements.DefaultEditorWindowBackend.UnityEditor.IEditorWindowBackend.OnRegisterWindow () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/WindowBackends/DefaultEditorWindowBackend.cs:101)
UnityEditor.HostView.RegisterSelectedPane (System.Boolean sendEvents) (at /Users/bokken/buildslave/unity/build/Editor/Mono/HostView.cs:503)
UnityEditor.HostView.SetActualViewInternal (UnityEditor.EditorWindow value, System.Boolean sendEvents) (at /Users/bokken/buildslave/unity/build/Editor/Mono/HostView.cs:83)
UnityEditor.DockArea.SetSelectedPrivate (System.Int32 value, System.Boolean sendEvents) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:99)
UnityEditor.DockArea.AddTab (System.Int32 idx, UnityEditor.EditorWindow pane, System.Boolean sendPaneEvents) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:195)
UnityEditor.DockArea.AddTab (UnityEditor.EditorWindow pane, System.Boolean sendPaneEvents) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:188)
UnityEditor.EditorWindow.CreateNewWindowForEditorWindow (UnityEditor.EditorWindow window, System.Boolean loadPosition, System.Boolean showImmediately, System.Boolean setFocus) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:1226)
UnityEditor.EditorWindow.Show (System.Boolean immediateDisplay) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:666)
UnityEditor.EditorWindow.Show () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:658)
UnityEditor.EditorWindow.GetWindowPrivate (System.Type t, System.Boolean utility, System.String title, System.Boolean focus) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:717)
UnityEditor.EditorWindow.GetWindow (System.Type t, System.Boolean utility, System.String title, System.Boolean focus) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:732)
UnityEditor.EditorWindow.GetWindow[T] (System.Boolean utility, System.String title, System.Boolean focus) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:798)
UnityEditor.EditorWindow.GetWindow[T] () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorWindow.cs:772)
ExampleWindow.ShowExample () (at Assets/ExampleWindow.cs:10)

  1. Resolution Note (fix version 2022.2):

    Fixed in: 2022.2.0a1

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.