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

z-index support

Discussion in 'UI Toolkit' started by Stardog, Aug 30, 2019.

  1. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,886
    How can I control the order of elements from CSS?

    VisualElement.BringToFront gets overwritten in certain circumstances, like when a new child is added.
     
  2. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    439
    Hi @Stardog!

    Unfortunately, Z-index is not supported in USS. However, you can control the ordering of the elements via the hierarchy. The parents are drawn before the children.
     
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    As I understand it ... the main reason for z-index to exist is for the many cases where parents CANNOT be drawn before the children.

    A year later ... z-index still not supported?
     
    SolidAlloy, Haxel0rd, Romeno and 4 others like this.
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    I agree z-index will be useful to have but I'm curious to understand your specific case where it is not an option to use the hierarchy for ordering. It's not always fun or elegant but I've yet to hit a use case where I could not use the hierarchy in place of z-index but maybe I've just not hit hard enough problems yet. :)
     
  5. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    753
    I don't know if this is a use case because I cannot switch to UIToolkit yet for this menu (as I need shader support), but I am certain it will.

    When you click on one of the levels in this menu, the black background element will rotate on the Y axis, hide the level number, then flip back and grow until it covers the entire screen. I think if I had to put that element in front of the hierarchy, it will make everything else adjust around it (already had issue with another menu and reordering elements).

    I would need to use z-index in this instance to make sure the black level background can cover all other UI.
     
  6. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    I don't know about the "rotate on the Y axis", that won't be possible yet with UI Toolkit in screen space. But having one of the level shapes expand to take up the entire screen shouldn't be too bad. What you can do is spawn a new element that sits on top of the entire menu using Absolute position and have it grow, starting with the active item, to take up the full screen. It would be after the menu container in the hierarchy and so would take up the screen. You would actually still need to do this even with z-index, because growing your active item in relative position would displace the other level items and never actually go on top of them.
     
  7. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    753
    That’s true. Thanks for pointing that out.
     
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    I'm very surprised that you haven't seen this. Maybe there's another way of hacking around it that works (if so, I'd love to know it - I couldn't google anything for it, I guess because z-index is so easy to use that no-one would need a hack?) It's happened on most non-trivial CSS layouts I've made, especially any that are responsive, that work on multiple screen resolutions, that have user-supplied content, etc. How big is your set of test cases?

    In my experience of CSS this is a feature that is frequently used in two classes of situation:
    1. Fixing edge-cases in UI
    2. Doing innovative/exciting UI

    Classic example of 2 is the "two images that both overlap each other" trick (e.g. an image inside a border, where parts of the image overlap the border and other parts underlap it).

    Classic example of 1 is fine-grained control of overflow - e.g. text that you need to be inside one element but overflow a different element. Or underflow one element and overflow another. USUALLY: because margins / padding are insufficient to allow the text to show through - which is USUALLY because text is labelling something, and labels conceptually need to float above graphics. (*)

    My immediate case:
    Root rect has a label at top
    Child rect has a background color
    when root object padding is small / child margins are small: the text gets cut off by the child rect

    In CSS, this kind of thing isn't common but happens sooner or later (at least once) on almost every project, but it's trivial to solve: you z-index it and then move on, so quickly you probably forget you even needed it :).

    (*) if z-index didn't exist, we would have to stop using flexbox for text in most of the UI's we wrote: all text would have to be manually positioned simply so that we could place the text in a separate layer above the graphics layer.

    This is what I'm currently doing as a workaround. It so far requires almost 4x as much code to achieve in UIToolkit what would be needed if z-index were supported. It's essentially the same as writing an IMGUI example: we have to manually position everything.
     
    Romeno likes this.
  9. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    Screenshots are worth a million words. :) All three cases you give above, from what I can get from just the description, I can easily implement them without z-index or absolute positioning. My point is that I feel like I'm missing the "edge" part of your edge-cases.

    I don't see how this is possible with z-index. You have to split either the border element or the image in two. Z-index doesn't let you say "make half of this element go on top of something and the other half under that same something". I'm going to assume you are, in fact, implying some sort of splitting, where the image element is split into two elements with one behind the border and the other above the border element. This is quite easy to do without z-index. You have your container element that has 3 children (image-background, border, image-foreground), where all children use Absolute position with left/top/bottom/right set to 0 (or some other offset). This makes them overlap each other like layers, producing what I think is your desired result?

    This really requires a screenshot or a lot more specifics. If the "graphics" part that text attaches to are just elements, then, as I said in another post, you can always anchor a Label to an element. You can either use GCE on your target graphic element to "manually" position your Label or you can have your Label be a child of your graphic element but outside of its actual rect (overflow is visible by default) and then you get the "anchoring" for free. Neither approach requires z-index. "On top" just means "be the last child in the list of children".

    I don't fully understand the problem here. Why would small padding/margin cause anything to be cut off?
    I created something like what you describe, with zero parent padding and zero child margin. What am I missing?
    upload_2020-11-12_20-41-11.png

    I'd encourage you try the UI Builder for a bit. It's all done with UI Toolkit without using z-index and only using Absolute position "layers" where that's exactly what they are, layers. For example, the selection highlight blue border in the Canvas that can't be part of the actual user document hierarchy and needs to float on top.

    But again, I feel like I'm missing the finer details of your cases. Screenshots would help a lot.
     
  10. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    As I understand there is still no way to set `z-index` yet.

    The workaround proposed here, to change the hierarchy, is out of question if you are using flex layout. For example, you want your element to be in the middle when calculating layout, but visually be in front of other elements.

    Use cases like this are countless. Overlays (tooltip, dropdown menu etc.), drag-drop, sticky header...

    Even if you are using absolute positioning, you need to watch out for elements added after you changed the hierarchy, and manually put your element at the end of hierarchy again. I think the code loses declarative-ness like this.
     
    RiseBasti, orb_9, florianBrn and 7 others like this.
  11. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    For what it's worth: implementing this correctly in Unity outside of UIToolkit (i.e. implementing it in UnityUI) took me something like 20 minutes (won't work for UIToolkit - this was my own Flexbox re-implementation). But my point is: I don't think there's a technical reason why UIToolkit violates the specification here, it's not hard to do correctly.

    (when the UIToolkit team made posts about: following the official specification isn't important because they (Unity) don't understand the purpose of those features and never use them themselves ... and they argue about my app design and say that it's *me* who's wrong for trying to use the features that are guarnteed, that are required, by the spec ... I lost interest)
     
    Hexane likes this.
  12. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    Don't get us wrong. We understand the handiness of z-index, and would like to implement it eventually. It's also been requested internally. In most cases, we managed to work around it otherwise, by relying on the hierarchy and absolute positioning. It is indeed cumbersome in some instances, but gets the job done. It's just that we can't tackle everything at the same time, and have to establish priorities. Some highly requested features don't have a workaround and end up being prioritized over this one. Runtime support was one of those, for example.

    If z-index was easy to implement, it would likely be implemented already. But it's not. It requires significant changes in the way we create, update and remove the rendering commands. In order to achieve scalable updates when the UI changes, we need to track and maintain a lot of state. This tracking is very complex and contains many assumptions that were designed with a depth-first rendering order in mind. Some hierarchical state propagation would be broken if elements could suddenly be drawn in a different order. We may have to implement a kind of ghost hierarchy that the renderer would consume in a depth-first manner, we'll see.

    Btw, I pinged our product manager to make sure he gets your input about the priority of z-index.
     
    Last edited: Mar 1, 2021
    feelie75, Nexer8, RKar and 2 others like this.
  13. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    If there is no way to make z-index work without sacrificing performance to the garbage rendering levels of UnityUI then it is better to make sure it comes with a warning you cant disable.
     
  14. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    199
    z-index, amongst other desired UI Toolkit updates, would increase my productivity for sure. I find it a bit off that it wasn't planned for from the beginning.
     
    mengkaima, DrViJ and Romeno like this.
  15. Romeno

    Romeno

    Joined:
    Jun 24, 2013
    Posts:
    34
    Thanks for the explanation. I understand that there are difficulties implementing performant UI and apparently the architectural basis was developed not considering the z-index feature. But I want to ping that this is a crucial feature.

    UIToolkit seems to fix layouting of controls compared to the UGUI by using flexbox - that's great and it is a vast improvement. But the absence of the ability to sort controls on the screen the way you want is like a huge flaw in the design of UIToolkit. Like you are not even UI for mobile apps it is UI for games that presume UIs can be twisted and bent as hell.

    You asked for the use case. I don't know this is such a basic feature I struggle to make a concrete use case...

    Suppose you want to create FTUE (first-time user experience). You need to blacken all UI except for one button or other visual element and on top of it draw a finger and a tooltip.
    In UGUI we were doing this with Canvas and override sorting.
    What I would do (if z-index existed): added a transparent black overlay, change the z-index of a said button, add a finger and a tooltip on top of it. How would you do that without a z-index? The only way I could think of (which is hacky as hell) is: hide the button using
    Code (CSharp):
    1. visibility: hidden
    , get the position of a button, clone the button, set absolute position, and set position same as hidden button. Z-index is such a straightforward thing and you need to have it.
     
  16. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    It's been some time since this thread was started. In the meantime we also internally identified other valid use cases. So I don't think that the practicality of this feature needs to be debated anymore. The question is more about prioritization. Our new roadmap contains this card which covers z-index. Make sure to have a look at it and and report your interest: https://portal.productboard.com/xvo8kmgtx7tkv7desh8cyaj7/c/520-depth-ordering

    Btw, z-index requires what we internally refer to as "out-of-order rendering", which is closely related to the notion of stacking context in the CSS world. Rendering-wise, this is required to implement many other cool features, like subtree post-processing, subtree caching (variable rate subtree rendering), etc. So it's definitely something that we keep on our radar.
     
    Last edited: Jun 2, 2021
    Nexer8, Kirsche and DrViJ like this.
  17. DrViJ

    DrViJ

    Joined:
    Feb 9, 2013
    Posts:
    154
    Sounds great!
     
  18. brinca

    brinca

    Joined:
    Mar 29, 2015
    Posts:
    33
    I'm surprised no one mentioned the most obvious use case: tabs!
    Tabs have to ordered a certain way, but if they overlap, then we want the selected one to be rendered in front of the others, but we them to stay in the same position (changing the hierarchy would push them to the end of the layout).

    See an example:
    upload_2021-12-3_16-2-52.png
    (The FORMS tab should remain the third, but be rendered in front of the OTHER tab)

    I guess we can do some trickery with absolute positioning, a ghost element and some scripting, but having z-index available would make things way simpler... ;)
     
    Hexane, feelie75, orb_9 and 10 others like this.
  19. Oneiros90

    Oneiros90

    Joined:
    Apr 29, 2014
    Posts:
    77
    Any news about z-index in USS?
     
    Haxel0rd likes this.
  20. ethayer

    ethayer

    Joined:
    Feb 1, 2022
    Posts:
    1
    At least give us the
    order
    layout property
     
  21. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323
    We've been busy with the vector API and some performance improvements but we still intend to implement it. We don't have an ETA yet.
     
    yongbinkim and worldsayshi like this.
  22. Marcolino101

    Marcolino101

    Joined:
    Oct 15, 2015
    Posts:
    4
    I am currently working on a project that involves drawing items in a grid. Not having z-index means that items larger than one grid square get rendered behind other UI slots even if their positioning is set to absolute and overflow is set to shown on their parent VE's. In this example the rifle is two inventory slots wide and even though it is positioned correctly it is not drawn correctly because it is clipped by the next inventory slot. Overflow is set to shown so I don't believe clipped overflow is the problem.
    Attached also is a screenshot of the UI toolkit debugger showing what size the displayed item should have.

    Clipping.png
    WithDebugger.png
     
    Last edited: Jun 30, 2022
    MostHated likes this.
  23. cb0d

    cb0d

    Joined:
    Mar 18, 2022
    Posts:
    20
    Bumping for interest...

    With the current implementation of element ordering (no z-axis), is the following the best way to get a pop-up window to appear above all other UI?

    - place the UI element as a child of the UI root with absolute position

    Let's say I wanted to implement custom drop-down windows, which show a drop-down window when the user clicks on a certain UI element. Would the best way to achieve this be to place the new window as a child of the UI root at an absolute position corresponding to the drop-down selection button?

    If anybody has recommendations for implementing custom drop-down windows, or popup windows that appear nearby other UI elements, do share!
     
  24. Oneiros90

    Oneiros90

    Joined:
    Apr 29, 2014
    Posts:
    77
    I guess it is, since UI toolkit developers followed the same approach with the Dropdown element (try it with the debugger, you'll see the dropdown popup appearing as last child of the root)
     
  25. cb0d

    cb0d

    Joined:
    Mar 18, 2022
    Posts:
    20
    Interesting. In that case, how can I position a new element as a child of root with absolute positioning relative to some element deeper in the hierarchy?

    For example, I was thinking of having an "OnFocus" event which places the popup window near/below the element focused (such as a button clicked):

    Code (CSharp):
    1.     private void OnDropdownFocus(FocusEvent evt)
    2.     {
    3.         VisualElement element = (VisualElement)evt.target;
    4.         var target_position = element.LocalToWorld(element.transform.position);
    5.  
    6.         popupWindow.style.position = Position.Absolute;
    7.         popupWindow.transform.position = popupWindow.WorldToLocal(target_position);
    8.         popupWindow.style.display = DisplayStyle.Flex;
    9.     }
    This isn't working because I don't know which "position" property should be used and how it can be applied to the popup window. Anybody understand how to manipulate the position of UI elements via C# code? The API in the documentation isn't very clear in this regard.

    EDIT: I've found that using the style.left / style.right / style.top / style.bottom achieves what I'm looking for:

    Code (CSharp):
    1.     private void OnDropdownFocus(FocusEvent evt)
    2.     {
    3.         VisualElement element = (VisualElement)evt.target;
    4.         var target_position = element.LocalToWorld(element.transform.position);
    5.  
    6.  
    7.         popupWindow.style.position = Position.Absolute;
    8.         popupWindow.style.left = target_position.x;
    9.         popupWindow.style.top = target_position.y - (popupWindow.layout.size.y / 2) + element.layout.size.y;
    10.         popupWindow.style.display = DisplayStyle.Flex;
    11.     }
    This code results in the popup window appearing directly below the button pressed:

    Before button press:
    upload_2022-9-10_13-39-22.png

    After button press:
    upload_2022-9-10_13-41-43.png

    This should be enough to implement a custom drop-down popup comprised of all sorts of custom elements.
     

    Attached Files:

    Last edited: Sep 10, 2022
  26. Oneiros90

    Oneiros90

    Joined:
    Apr 29, 2014
    Posts:
    77
    I'm not sure I get your goal... why don't you use the default dropdown popup? It looks to me that your case can be implemented just with that
     
  27. cb0d

    cb0d

    Joined:
    Mar 18, 2022
    Posts:
    20
    I initially tried using the default dropdown, but it is very difficult and restrictive to customize and add styles. Especially if I want to make the popup window contain multiple custom elements. Unless I'm missing something and this can be done with the default dropdown.

    Also, with the custom dropdown I'm able to programmatically create and populate the dropdown popup via C#, so that the options that appear directly correspond to the actual data used in the game. This way I can add new items/options and the UI will update without needing to manually create a new UI element.
     
  28. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    There were (are? In all fairnes: last time I checked was almost 6 months ago) fundamental bugs in the design of the UIToolkit dropdown/popup, which made/make it a very poor choice in general if you intend to customize/extend/use for a real game where you want to have custom UI. It works fine for cases where you're doing NOTHING interesting, but even basic nice UI elsewhere (using mouseevent listeners on OTHER VisualElements) causes some horrible interactions with the default dropdown). IIRC the first ones I logged 1.5 years ago and got the eventual response "yes, but ... it would be difficult for us to implement it better, so we're not going to".

    (I agree with the UIToolkit team that popups x-platform is hard! (then again: that's what we pay Unity for, so ... not sure why 'it's difficult' was a reason not to do it better). I also agree that *if* you're going to start from a partial implementation of Flexbox, so you're unable to use some of the core features, then yeah - doing popups is going to be extra tough! I wouldn't want to have to do it myself if I could avoid it)
     
    Last edited: Sep 12, 2022
  29. Isirode

    Isirode

    Joined:
    Jun 6, 2019
    Posts:
    4
    Hello,

    I've noticed that the link indicated has disappeared (https://portal.productboard.com/xvo8kmgtx7tkv7desh8cyaj7/c/520-depth-ordering).
    The whole 'UI Design' section has disappeared actually.

    But when scrolling the latest USS documentation (https://docs.unity3d.com/2023.1/Documentation/Manual/UIE-USS-SupportedProperties.html), I could not find it.

    Can I know if the feature is present elsewhere or if it will be present in the future ?

    There is a lot of use-cases where this would be very useful.

    Thank you in advance,
     
    feelie75 likes this.
  30. Murderbird

    Murderbird

    Joined:
    May 27, 2020
    Posts:
    1
    I was attempting to create a tabbed UI and assumed that z-index existed as this is CSS/Flex based UI. It looks like there is work in pipeline but I haven't seen any update in a while. I'll just bump this to see if there has been any follow up.
    I figure I could hack a solution using something like:
    Code (Boo):
    1. //Hide
    2. tabContent.style.display = DisplayStyle.None;
    3. // show:
    4. tabContent.style.display = DisplayStyle.Flex;
    However it's a little janky compared to what I initially envisioned.
     
  31. Isirode

    Isirode

    Joined:
    Jun 6, 2019
    Posts:
    4
    I do not know for what problem you had to use this solution, but I had found the same solution (I used both a mix of the display property and the visibility property) for a pop-up menu system and a select VisualElement.

    But I clearly remember the popup of the Select (the options) to be displayed behind children of the same parent, even repositionning them in the hierarchy did not work, since it's size could be bigger of the parent element (it's height notably, since you could have a lot of options to choose between, but it's width as well, if the option's name is long), it would be shown behind the siblings of the parent.

    So I had to pass a VisualElement as a parameter, one of the top most element of the hierarchy, so that it would be positionned absolutly at the correct position, on top of all other elements, without modifying the layout of the element.

    But this made his use inside the UI Builder very complex, since I could not tell which parent I would need to use to insert the popup beforehand, and using a string parameter (to pass the ID of the container), and navigate the hierarchy of the parents to find this element did no seem very elegant.

    I think, if the issue I had in this thread is a bug, and if Unity want to fix it, that a z-index could be useful here as well (if shared with the GL draw calls).

    This is complexifying the code a lot, for something that could have been solved with a single USS line code.

    I had this problem a while ago, and I had found this thread, and I had seen the roadmap, and I thought that it would have been implemented after a few months.

    I had this kind of problems when making a similar library in Javascript, and the z-index turn-out to be the best solution.
     
  32. feelie75

    feelie75

    Joined:
    Dec 30, 2020
    Posts:
    2
    Just started learning Unity a few days ago (been C# programming for years though). Was also very surprised to find no z-index support. Most tutorials online seem to rely on clicking and dragging stuff around and using the editor to change the hierarchy, etc, which is fine for some people, I just prefer to do everything in C# so I see how everything is set up just by looking at the code and not having to use the editor for much. So z-index would be super handy for that, and of course ALL the reasons mentioned in this wonderful thread.

    I do not see Depth Ordering on that roadmap either. Is it no longer under consideration, or is it still a "someday after other priorities"? Like.... within a year? just curious. Thanks for your transparency and feedback!
     
  33. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    Doing this the other way around ... I had an example today where having Flexbox's built-in 'order' feature made it take a few seconds to make the UI, compared to having to corrupt the layout with hacks to make it work without.

    (note: since UIToolkit is missing BOTH the required features (either would have been enough to make this work, both would have been better) - z-index and flex-order - you cannot do this in UIToolkit. It works fine if you implement Flexbox correctly though)

    Because UnityUI already is hardcoded to do z-index from Hierarchy order, all I needed was to override Unity's 'positioning / flow from hierarchy order' to be set on a per-element basis, and then use Unity Hierarchy to set the z-indexes. This won't work for all cases, but for some UIs its a lifesaver:

     
  34. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Old thread but I was just searching for z-index.
    Damien said, well just change the hierarchy, and it makes sense. (to an extent - changing the hierarchy is not as trivial as applying a class with a z-index though, so just for the sake of accessibility I disagree)

    But for anything in-built, like a progress bar, we can't just change the hierarchy. So having z-index for that would be nice.
    Or should we not use built-in elements and rather copy them?
     
  35. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    83
    3 years later and this is still not in sight, it has been on the road map as "planned" since march 2021, is this crucial feature ever going to get support?
     
    TomMoore515, a4ism and Haxel0rd like this.
  36. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    @Unity:

    PLEASE IMPLEMENT Z-INDEX - NOW !!
     
    Last edited: Apr 5, 2023
  37. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    32
    z-index is also on my wish list
     
  38. digiwombat

    digiwombat

    Joined:
    Sep 26, 2013
    Posts:
    44
    To celebrate the one year anniversary of the last Unity employee post in the thread, I would like if my gift could be a new Unity employee post in the thread.

    Any news these past 12 months? Any hope for the feature seeing dev time? What are you guys up to instead?

    Since UIToolkit is recommended by the docs now for "Multi-resolution menus and HUD in intensive UI projects" so I do think it's fair for us to hope this gets a bit of active attention and communication considering the hierarchy ordering doesn't meet the expectations a lot of HTML/XAML-style UI devs are going to have.
     
  39. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Although I would also like to have an update from Unity team about ETA here is their roadmap which states that it's a "planned" feature.
     
  40. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,873
    I use UIToolkit every day, but I don't believe UIToolkit is ready for those, except for toy examples. Major bugs keep appearing a little bit too often / recently still. I would aim for 6 months from now to play with it, and not to start development until 9-12 months from now if you're using in production.

    I don't normally mention my own assets, but ... you can get Flexbox with both z-index and flex-order right now, working great at runtime with live-editing (no offline editing needed), inside UnityUI (see my sig for links). Doesn't use UIToolkit, so bypasses all the issues there.
     
    ontrigger and RyanCantCode like this.
  41. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    327
    Hey folks. We're currently reviewing our plans and updating our roadmap, and z-index will be part of our next release cycle.
     
  42. SamuelAsherRivello

    SamuelAsherRivello

    Joined:
    Jan 16, 2011
    Posts:
    36
    Sounds great.

    The case for me is when I have a list of items and a custom "item:hover" psuedostate enlarges the scale (e.g. from 1.0 to 1.1) then I want that item in front of its siblings. Doing that in USS is desirable.

    Capturing that moment in C# instead and manually sorting (e.g. "VisualElement.BringToFront") is an undesirable workaround. Doing that in C# is undesirable.
     
    Haxel0rd likes this.
  43. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    This is really great news, thank you very much for picking this up!

    I have made 2 drag&drop inventory systems so far with UI Toolkit and i can confirm there are moments when you need z-index. For example: Player clicks on a window that is currently behind another window. So the window that gained focus in the back, should jump to front.
     
  44. ProFiLeR4100

    ProFiLeR4100

    Joined:
    Dec 27, 2015
    Posts:
    12
    Not only tabs, but also buttons or other elements which have interactions with user.
    Here is an example, where arrow must be drawn on top of all other elements.

     
  45. dmitro1982

    dmitro1982

    Joined:
    Sep 20, 2018
    Posts:
    6
    Here the most common example of using Z index in UI. All logos, labels decorative parts are set with Z index.
    My dialog box is not a parent of header, they are on same level.
     

    Attached Files:

  46. Hellfim

    Hellfim

    Joined:
    Sep 11, 2014
    Posts:
    92
    Well, if they are no the same level (children of the same parent) you can set direction to column-reverse