Search Unity

Bug GUILayout.Window -> Resolve of invalid GC handle. The handle is from a previous domain. The resolve

Discussion in 'Editor & General Support' started by nuverian, Dec 13, 2022.

  1. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,

    BUG

    With an EditorWindow utilizing GUILayout.Window, Unity throws the following error when entering play mode if that Editor Window is open:

    Code (CSharp):
    1. Resolve of invalid GC handle. The handle is from a previous domain. The resolve operation is skipped.
    2. UnityEngine.GUILayout:Window (int,UnityEngine.Rect,UnityEngine.GUI/WindowFunction,string,UnityEngine.GUILayoutOption[])
    3. SomeEditor:OnGUI () (at Assets/Editor/SomeEditor.cs:14)
    4. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    ---

    REPRODUCTION

    This can be reproduced with the following simple script in an otherwise empty project:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class SomeEditor : EditorWindow
    5. {
    6.  
    7.     [MenuItem("Tools/SomeEditor")]
    8.     public static void ShowWindow() {
    9.         GetWindow<SomeEditor>().Show();
    10.     }
    11.  
    12.     void OnGUI() {
    13.         BeginWindows();
    14.         GUILayout.Window(0, new Rect(20, 20, 20, 20), WindowCallback, "Hello");
    15.         EndWindows();
    16.     }
    17.  
    18.     void WindowCallback(int ID) {
    19.         GUILayout.Label("Error on enter/exit play mode");
    20.     }
    21. }
    1. Import the attached script (or copy/paste the code above).
    2. Open the EditorWindow ("Tools/SomeEditor").
    3. Enter play mode with the EditorWindow open.
    Tested in Unity 2021 and 2022. This error was not present in Unity 2019.

    Thank you.
     

    Attached Files:

    abegue likes this.
  2. Toomblercazz

    Toomblercazz

    Joined:
    Oct 8, 2016
    Posts:
    4
    I have noticed exactly the same thing, using 2020.3.42f1. (Haven't made a minimal example though)
     
  3. nobnak

    nobnak

    Joined:
    Mar 12, 2019
    Posts:
    1