Search Unity

Visibility: Inline vs inherited (ListView)

Discussion in 'UI Toolkit' started by Lance-Grooms, Apr 8, 2020.

  1. Lance-Grooms

    Lance-Grooms

    Joined:
    Mar 24, 2016
    Posts:
    26
    Intuitively, if a parent VisualElement is hidden, I would expect children to be hidden as well. This turns out to be the case when elements use "inherited" but NOT "inline" visibility. This is particularly nasty with something like a ListView where there tons of nested elements.

    Here is an example using a tabbed panel system. Panels are hidden if not the selected tab.

    Fig 1: ListView on a visible panel (all good)
    Fig1.png

    Fig 2: List view "inline" elements still visible when parent panel is hidden
    Fig2.png

    Is there a solution for this issue? I'm hoping there is something basic I'm missing. If not, are there any plans to implement a more robust system? (VisibleInHierarchy etc)

    Thanks!
     
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    use `style.display = Display.None` from c# or `display : none` from uss
     
  3. Lance-Grooms

    Lance-Grooms

    Joined:
    Mar 24, 2016
    Posts:
    26
    Well that was an easy 2-minute fix. Thank you for the quick response. If I may pose a quick follow-up:

    From this I assume that:
    1) an element is included in the layout regardless of its visibility status
    2) Display.None completely excludes the entire hierarchy branch from the layout engine

    Is this correct? (And thanks again.)
     
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    You are correct for both 1) and 2).