x


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.

more ▼

asked Jun 10 '10 at 09:38 AM

Ash gravatar image

Ash
23 3 3 4

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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
     }
}
more ▼

answered Jun 10 '10 at 10:04 AM

qJake gravatar image

qJake
11.6k 43 78 161

(comments are locked)
10|3000 characters needed characters left

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)

more ▼

answered Apr 14 '11 at 12:03 AM

filixix gravatar image

filixix
16 1 1 5

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 10 '10 at 10:12 AM

newbrand gravatar image

newbrand
159 1 1 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3690
x842
x161
x83

asked: Jun 10 '10 at 09:38 AM

Seen: 7678 times

Last Updated: Jun 10 '10 at 09:38 AM