- Home /
GUI Message Box Handling
With the unity GUI I have created a message box via BeginGroup etc.
But Im wondering what is the best way for this to capture all the input so that no other controls can be used until this messagebox has been handled?
So that the game (all other GUI controls) essentially waits for a response in this message box.
Ashley.
Answer by qJake · Jun 10, 2010 at 10:04 AM
Just turn off all the other GUI controls so the message box is the only one shown. There is currently no way to make a part of a GUI Modal.
Something like this:
bool MessageBox = false;
void OnGUI() { if(MessageBox) { // Message Box GUI Code } else { // Regular GUI Code } }
Answer by filixix · Apr 14, 2011 at 12:03 AM
hi everyone! Greetings from Lisbon!
Talking about MessageBoxes a doubt came up:
is there any way to have something like this bilt on a webplayer?
if (UnityEditor.EditorUtility.DisplayDialog(title, body, "Yes", "No"))
print ("Yes");
else
print ("No");
I mean: is there any easy way to do it without having to draw GUI.Box, GUI.TextArea and GUI.Buttons and use a boolean to let you know the dialog is still open?
Thank you all
Edit: I'm going to open a new post with this question (20-04-2011)
Answer by newbrand · Jun 10, 2010 at 10:12 AM
Normally you could use a box big enough to fill the screen and then show your message box. However, this doesn't work because the unity GUI has a nasty bug that allows gui elements that are behind other gui elements to still receive user input like clicks or mouse hovers.
Because of this behaviour it is probably the best and definitely the easiest solution to use a variable isModalDialogShowing: boolean that is visible from all scripts. If you want to show a modal dialog like your message box, set it to true and don't handle any other user input or show gui elements unless isModalDialogShowing is false.
Your answer

Follow this Question
Related Questions
Help With Message System Script 1 Answer
GUI box problem? 0 Answers
Change colour of GUI box, keep round corners. 0 Answers
Converting world coordinates to screen coordinates 1 Answer
Android Messag 0 Answers