Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

the new GUI.ModalWindow -- how to use it?!

Discussion in 'Immediate Mode GUI (IMGUI)' started by Millipede, Apr 12, 2013.

  1. Millipede

    Millipede

    Joined:
    Feb 28, 2013
    Posts:
    23
    Hi there,

    Does anyone have any information about the newly added GUI.ModalWindow, added in 4.1.2?

    The docs are bare. In the release notes it mentions being able to open a modal window who's events are sand boxed so that other sources can't listen into input events. It's sounds great, I'm just not sure how to use it. It sounds perfect for a situation I have with a client who is concerned about security and figured I can use it for my login form.

    So is this what the window is intended for? and how to do go about adding buttons and labels to the window? I can see how you can push in a single piece of GUIContent, but how would add multiple and position them??

    Thanks
     
  2. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    Modal means that other elements in the app don't react to mouse clicks when the window is poped-up. With other frameworks, this is usually accompanied with the greyish background over the whole screen (but behind the window) just to indicate that nothing else that a window would respond to mouse events.

    It has nothing to do with security.
     
  3. Millipede

    Millipede

    Joined:
    Feb 28, 2013
    Posts:
    23
    Hi there... thanks for the response, to elaborate on what I meant about security is that it prevents any 3rd party libraries of code from listening in to input events which in effect increases the security of a login form. The modal aspect of the window isn't so much something that I need, but more so the sandboxed input that comes with it. However the part I'm unable to figure out is how to use this modal window to present some custom forms and my own content. Some documentation or examples in the docs would be brilliant!!
     
  4. SlyRipper

    SlyRipper

    Joined:
    Jun 19, 2012
    Posts:
    251
    Look for "Window" the modalwindow ist just a new form with some additional stuff like dkozar mentioned, other GUI elements will be blocked so a button next to the ModalWindow wont work.

    This ModalWindow is nothing really new, you can use it as you use a normal Window function. Search the docs for it :)
     
  5. Millipede

    Millipede

    Joined:
    Feb 28, 2013
    Posts:
    23
    Hey... thanks for that! It's so obvious now, I hadn't thought that the modal window was a similar to or extending the GUI.Window class, which is another class I didn't notice existed. The docs definitely need some attention on the new modal window class, there's nothing there at all. For anyone looking for the docs mentioned above, here they are:

    http://docs.unity3d.com/Documentation/ScriptReference/GUI.Window.html

    Thanks again!