have such code
bool b = EditorUtility.DisplayDialog(\"Test\",
\"Reset or continue?\", \"Reset\", \"Continue\");
if (b)
{
ResetGame();
}
<
Any Unity class that includes the word "Editor" or came from the UnityEditor
namespace means that the class
is designed to used in the Editor only and will only work in the Editor. So EditorUtility
is for Unity Editor only.
You need to implement your own Modal Window and to be able to this, you must understand basic Unity UI such as creating buttons, panels, texts. So learn the Unity basic UI first. All you need to do is to put the UI Objects in a panel then acivate/deactivate them when needed.
For example, this is your dialogue panle:
public GameObject dialoguePanel;
to show a dialogue of the UI Panel
dialoguePanel.SetActive(true);
To hide it:
dialoguePanel.SetActive(false);
You can subscribe to the dialogue's button or UI controls events dynamically with onClick.AddListener
. See this post for more information on how to subscribe to UI events.
If you still can't implement your Modal Window, then follow the tutorials below as that's exactly what you are looking for.
Unity Tutorial for a generic modal Window:
MAKING A GENERIC MODAL WINDOW Part 1
MAKING A GENERIC MODAL WINDOW Part 2
MAKING A GENERIC MODAL WINDOW Part 3