Search Unity

GUI enabled/disable

Discussion in 'Immediate Mode GUI (IMGUI)' started by frigorifico, Feb 13, 2014.

  1. frigorifico

    frigorifico

    Joined:
    Sep 5, 2013
    Posts:
    37
    hi all,

    its like this i have a form for people to fill (user registration), and this form its on a pop-up window , when i call that window i need the elements on the main gui to be disabled, so i do GUI.enable = false, this part is all fine and working.

    in unity documentation:
    "Set this value to false to disable all GUI interaction. All controls will be draw semi-transparently, and will not respond to user input."

    is there a way to control how much is the semi-transparency? more or less alpha?

    thx
     
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    What you are looking for is probably in the color field of the GuiStyle you're using. Set the 'a' property to the value you want between 0 and 1 and you'll have your alpha where you want it.
     
  3. frigorifico

    frigorifico

    Joined:
    Sep 5, 2013
    Posts:
    37
    hi,

    thx for sugestion _met44 but it is not the background of the pop-up window i want to change its the buttons that are draw in "main gui".

    1ª image no pop_up windo and GUI.enable = true
    $img_sem_pop_up.png


    2º image pop_up windo and GUI.enable = true
    $img_pop_up.png

    i want to be able to control how intence is the gray area. more or less gray
     
  4. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    If I understand correctly you want to create a modal window, then the method I described will work just fine.

    1 - Make a gui.box bigger than the screen size (x = -5, width = screen.width + 10 kinda thing)
    2 - before you draw it, set the style color of the box's background to what suits your needs (perhaps a rgba(0, 0, 0, 0.5) or rgba(0.25, 0.25, 0.25, 0.5) will do the trick, the 3 first values are the actual color, setting all 3 to 0 will be black, 1 is white, then the 4th is for the alpha so 0.5 will let what lies behinds pass though at 50%)
    3 - Draw you box using your custom style
    4 - Draw the popup window
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Code (csharp):
    1. if (whatever) {
    2.     GUI.enabled = false;
    3.     GUI.color.a = .1;
    4. }
    --Eric
     
  6. frigorifico

    frigorifico

    Joined:
    Sep 5, 2013
    Posts:
    37
    first thx for the help guys

    draw a black texture the full screen this controls what we let the player see in the background and of course keaping the aspect ratio
    Code (csharp):
    1.  
    2.             GUI.color = new Color(1,1,1,0.85f);
    3.             GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height),textura_preta);
    4.             GUI.color = new Color(1,1,1,1);            
    5.             GUI.enabled = false;
    6.  
    before i launch the gui.window i frist reactivate the gui
    Code (csharp):
    1.  
    2.  
    3.                GUI.enabled = true;
    4.                 GUI.skin = sk_window;
    5.                 janela_fazer_login = GUI.Window(0, janela_fazer_login, fazer_loging, "");
    6.                 GUI.skin = null;
    7.                 GUI.enabled = false;
    8.  
    after the gui.window is done i disable the gui again