Search Unity

Hide a button object

Discussion in 'UGUI & TextMesh Pro' started by pKallv, Sep 4, 2014.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    Could someone please help me to hide a button object?

    I have tried "backButton.GetComponent<Button> ().image.enabled = false;" and other things but not succeeded. Probably very simple :-(
     
  2. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    Finally found the answer. This is done by adding a Canvas Group and manipulate the Alpha property.
     
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    You can also just set the game object to inactive.
     
  4. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    I think i tried that but it did not disappear.
     
  5. secondbreakfast

    secondbreakfast

    Joined:
    Jan 5, 2013
    Posts:
    98
    Enabled isn't the same as active. Enabled is just for components. Active is for the entire game object. I would be really surprised if it didn't disappear since I use it all the time. There is a Game Object.SetActive method you can call or it's the checkbox next to the object name in the inspector.