Search Unity

Are to make a visible button become invisible

Discussion in 'Works In Progress - Archive' started by samcad, Oct 2, 2013.

  1. samcad

    samcad

    Joined:
    Sep 30, 2013
    Posts:
    1
    Pls, how can I make a button that is visible in visible in my scene
    thanks in advance
     
  2. miguelvesga

    miguelvesga

    Joined:
    Aug 1, 2012
    Posts:
    88
    1. Should be on 'Scripting'.
    2. You mean something like this?:
    Code (csharp):
    1.  
    2. void OnGUI()
    3. {
    4.     if(visible == true)
    5.     {
    6.         if(GUI.Button(new Rect(0,0,32,32), "button"))
    7.         {
    8.             visible = !visible;
    9.         }
    10.     }
    11. }
    12.  
     
  3. AustinK

    AustinK

    Joined:
    Dec 10, 2012
    Posts:
    86
    This question belongs in a difference part of the forum.

    I think people need more info. Are you using Unity's GUI system, NGUI, or what?

    But I think with most things in unity, including Unity's GUI, you can do gameObject.SetActive(false) to hide it if you don't want updates to happen while it's hidden.