Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How am I supposed to design UIs if I can't hide previous menus?

Discussion in 'UGUI & TextMesh Pro' started by Slight0, Aug 30, 2015.

  1. Slight0

    Slight0

    Joined:
    Dec 6, 2013
    Posts:
    28
    How can I toggle the visibility of UIs I've made in the editor window? Right now the only thing I can see is some checkbox to disable the gameobject. Problem with that being the gameobject stays disabled when the game starts and it is impossible to find a disabled gameobject with code.

    Am I supposed to just assign each one to their own layer? Isn't that abuse of the layer system? Layers don't seem to be made for this. Tested it and it doesn't work, toggling visibility of menus that are children of a canvas does nothing. They only respond to the "UI" layer's visibility.
     
    Last edited: Aug 30, 2015
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The correct way is to use the checkbox to activate and deactivate objects. Using Find is usually a bad idea anyway, since it's easy to break (change the name of the object and you have to remember to change your code). Just use a public variable and drag the appropriate object onto the slot in the inspector.

    --Eric
     
    Kiwasi and Senshi like this.
  3. DuffyT

    DuffyT

    Joined:
    Dec 16, 2014
    Posts:
    37
    Use empty gameobjects as parents of the menus you want to hide and use the recttransforms to anchor them (empty GO's) down over the screen. That way you can put the menus (children) anywhere you want in the scene using a simple script that put's them at position 0 again at game-start and they'll be exactly where you want them.

    Additionally I use canvas group components to hide them during gameplay until summoned, among other things.
     
    Senshi likes this.