Search Unity

Are there ways to hide a button (UI)?

Discussion in 'General Discussion' started by Wanderevil, Mar 2, 2016.

  1. Wanderevil

    Wanderevil

    Joined:
    Nov 8, 2014
    Posts:
    8
    So I've been experimenting with the UI and came up with an idea. When the game starts, the button should not appear and when the game ends the button would appear. I did this by placing the button UI as a child on an empty game object (which works) but I'm wondering if there's a code that let's you disable the button (interactable). If I use button.interactable the button is showing but not clickable. If there are other ways do enlighten me, thanks!


    (sorry if I posted on the wrong forum, in any case have me notified :D )
     
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    There's an umm.... UI forum
     
  3. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    gameObject.SetActive(true/false); ?
     
    Ryiah likes this.
  4. Wanderevil

    Wanderevil

    Joined:
    Nov 8, 2014
    Posts:
    8
    Oh, I didn't noticed that. Requesting thread to be move if possible :)
     
  5. Wanderevil

    Wanderevil

    Joined:
    Nov 8, 2014
    Posts:
    8
    Yeah, this is the one I used. Just wondering if there's another way other than making it a child of a game object.
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    There is also Button.Interactable

    Just disable the button object itself
     
    Ryiah likes this.
  7. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,573
    GameObject.SetActive(false). It will disappear.
    Button itself is a GameObject. To be precise, it is multiple gameobjects, last time I checked.
    Unity object model - Everything is a gameobject. Use that.
     
  8. Wanderevil

    Wanderevil

    Joined:
    Nov 8, 2014
    Posts:
    8
    Oh I see. I feel stupid now since I create an empty game object then drag the button onto it, where you can just directly drag the button to make it a reference D: