Search Unity

SetActive not hiding UI element and children.

Discussion in 'UGUI & TextMesh Pro' started by CanadianCheese, Feb 11, 2018.

  1. CanadianCheese

    CanadianCheese

    Joined:
    Mar 10, 2015
    Posts:
    12
    Hello All,

    I have a UI panel with several child elements. I want to toggle it on and off with a button. This should be simple, and toggling on works fine, but setActive(false) does not hide the UI element, though it does deactivate it and all its children in the hierarchy. It's still rendered, just inactive. Resizing the window will then update the UI without the element, though Canvas.ForceUpdateCanvases() does not.

    There does not appear to be a repaint call or equivalent, and it seems like that's not a great way to go regardless.

    Any suggestions?
     
  2. NicBischoff

    NicBischoff

    Joined:
    Mar 19, 2014
    Posts:
    204
    Might be a bug in the unity version you are using. A work around is to set the canvas alpha to 0.
     
  3. CanadianCheese

    CanadianCheese

    Joined:
    Mar 10, 2015
    Posts:
    12
    Yeah, updating fixed it. Was on 2017.3.0f1. 2017.3.1f1 Seems to have resolved it. Thanks!