1

Like the title says, I would like to create a custom EditorWindow that will block the Unity Editor in the same way as the EditorUtility.DisplayDialog does. I know how to create an EditorWindow, what I don't know how to do, is how to block the Editor until the user press a button in my custom EditorWindow or the window gets closed.

If anyone has an idea on how to approach this, I would really appreciate the help. Thanks.

0

1 Answer 1

1

Currently afaik there seems to be no way to archive this with a custom EditorWindow.


You can could have used ShowModalUtility for this (introduced in 2019.1).

Simply in the line where you would usually do e.g.

yourWindow.Show();

replace it by using instead

yourWindow.ShowModalUtility();

Show the EditorWindow as a floating modal window.

The utility window does not allow interaction with the editor while running. This means the EditorWindow.ShowModalUtility window is never hidden by the Unity editor. It is, however, notdockable to the editor.

Utility windows will always be in front of normal Unity windows. It will be hidden whenthe user switches from Unity to another application.

Note: You do not need to use EditorWindow.GetWindow before using this function to show the window.


BUT Just noted: Usually this should do the trick but unfortunately there seems to be a bug still existing since Unity 2019.1 was in alpha status .. apparently it wasn't fixed until now ...

As you can see in the linked bug report they say it has too low priority and pushed the possible fix to Unity 2019.3 .. which currently is still in alpha state .. so ... who knows if and when this will be actually fixed


Little fun fact: In the linked example code Unity has it wrong and used ShowUtility instead of ShowModalUtility

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your reply. I can't check this right now, but I will as soon as I get home. Just out of curiosity, do you know in which version of Unity was this method introduced to the EditorWindow class. I looked in Unity 5.1 and it doesn't show up.
oh lol apparently it was introduced in 2019.1 ... and is not working :D
As you can see in the linked bug report they say it has too low priority and pushed the possible fix to Unity 2019.3 .. which currently is still in alpha state .. so ... who knows if and when this will be actually fixed
Well then I will try it at home, but if is bugged, I cannot really confirm if this will work or not. I would like to mark this a the select answer, but I don't know if is right to mark it just because of the documentation's description.
I'm sorry it seems that currently it is simply not working ... :/
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.