I’m coding an EditorWindow. My problem is, when I use a EditorGUILayout.ColorField inside a GUILayout.Window, an ExitGUIException occurs when I click onto the color field.
I was able to boil down the problem to the following script:
using UnityEngine;
using UnityEditor;
public class TestEditor : EditorWindow
{
Color mColor = Color.green;
[MenuItem ("Test/TestEditor")]
static void Init()
{
EditorWindow.GetWindow( typeof( TestEditor ) );
}
public void OnGUI ()
{
BeginWindows();
GUILayout.Window ( 123, new Rect( 100, 100, 300, 50), DoWindow, "Ze window " );
EndWindows();
}
void DoWindow( int id )
{
mColor = EditorGUILayout.ColorField("Click here -->", mColor);
}
}
When I open the test editor and click on the color field, the following error occurs:
The error does not occur if I write the EditorGUILayout.ColorField simply into OnGUI instead of a window. Also, other fields like EditorGUILayout.CurveField or EditorGUILayout.FloatField don’t cause any problems.