I want to use dialog boxes (having two options).
I tried UnityEditor, but when I build the project to create an exe file, it didn't work because scripts having UnityEditor references are just working in edit mode. After searching on the Internet for hours, there were two suggestions (both didn't work).
First one: Using #if UNITY_EDITOR before code and ending with #endif. In this case, It was built without an error but there were no dialog boxes in my game at all.
Second one: Putting the script under Assets/Editor directory. In this case, I couldn't add the script to my game object. Maybe, creating a new script under Editor directory and pasting UnityEditor used lines in it would work but I couldn't figured out how to do this.
I used:
#if UNITY_EDITOR
if (UnityEditor.EditorUtility.DisplayDialog("Game Over", "Again?", "Restart", "Exit"))
{
Application.LoadLevel (0);
}
else
{
Application.Quit();
}
#endif
I also tried adding " using UnityEditor; " and encapsulating it with the preprocessor command I mentioned. It is also useless.
Is there anyone knowing how to use UnityEditor in run mode or how to create dialog boxes in a different way?