So I am creating an editor tool, this tool is open by clicking in a custom MenuItem
. This tool is open as a utility window using the GetWindow<T>(true, "title")
and ShowModalUtility()
methods. This new utility window has button that will open another utility window (different editor window type) using the same methods mentioned above.
I don't know if is a bug or by design, but it seems like having multiple utility windows open is not working properly. When the second utility window is open (by pressing the button in the first one) the rest of the unity editor is still block like it should, but the second utility window does not block the first one.
It looks as if being a utility window is a "static" thing and all utility windows have the same priority so you can click on any of them at any time.
Does anyone know how to block one utility editor window using another utility editor window?
P.S: I saw this post, and like I mentioned, I am using ShowModalUtility()
but it does not work properly for me, when I have both utility windows open.
UPDATE:
Here is a working example:
using UnityEditor;
using UnityEngine;
public class Test
{
public class TestWindow1 : EditorWindow
{
[MenuItem("TEST/Test Window 1")]
public static void Open()
{
var window = GetWindow<TestWindow1>(true, "Test Window 1");
window.ShowModalUtility();
}
private string text = "";
void OnGUI()
{
text = EditorGUILayout.TextField("Try To Write Here:", text);
if (GUILayout.Button("Open Test Window 2"))
{
TestWindow2.Open();
}
}
}
public class TestWindow2 : EditorWindow
{
public static void Open()
{
var window = GetWindow<TestWindow2>(true, "Test Window 2");
window.ShowModalUtility();
}
private string text = "";
void OnGUI()
{
text = EditorGUILayout.TextField("Try To Write Here:", text);
if (GUILayout.Button("Open Test Window 3"))
{
TestWindow3.Open();
}
}
}
public class TestWindow3 : EditorWindow
{
public static void Open()
{
var window = GetWindow<TestWindow3>(true, "Test Window 3");
window.ShowModalUtility();
}
void OnGUI()
{
EditorGUILayout.LabelField("NOTHING TO DO HERE!!!!");
}
}
}
So if you try to run this code then: You will open TestWindow1, if you try to write something in there it will work and if you try to click on the editor it will be block (this is correct behaviour).
If then you open TestWindow2 you should be able to write in window 2 but you should not be able to write in window 1 (window 1 should be block by window 2) here is the problem: At the moment of writing this update, I am able to write in window 1 even when window 2 is open, and also I can write in both window 1 and 2 when window 3 is open, in other words, the utility windows don't block each other, they only block the editor.