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

Bug How to manage several USS styles in TSS and/or UXML best circumventing UIBuilder bugs?

Discussion in 'UI Toolkit' started by cax-festenberg, Aug 10, 2023.

  1. cax-festenberg

    cax-festenberg

    Joined:
    Aug 10, 2023
    Posts:
    5
    Hi,
    we've been working on having several USS files used in the UIBuilder in a manageable manner. None of our attempts delivered satisfying results, and we would like to share the variants we went through. We used both Editor version 2023.1 and 2022.2.
    Generally we unfortunately have to conclude that the UIBuilder is far from being smoothly usable and full of bugs (e.g. saving the UXML often succeeds at the second saving Ctrl+S only, after setting values twice)


    1. Adding several USS files into an UXML
    Pro: Works as specified, all added USS show up in the stylesheet window and have effect.
    Contra: When managing >100 UXML files one needs to add generic USS files again and again for each UXML. This seems suboptimal.

    2. Using a TSS file with additional USS
    Pro: Would be the optimal way keeping UXMLs small
    Contra: The additional USS files were bluntly ignored in any UXML in our attempts (2023.1 and 2022.2), nor where they shown in the UIBuilder style sheet window. This seems to be a bug. What do you think?
    [EDIT: Additional USS in TSS files are only ignored if saved with the default name "UnityDefaultRuntimeTheme.tss"(!). If saved under a different name they are effective, but still not shown explicitly in the UIBuilder and thus not editable there.]

    3. Importing additional USS via "(at)import url("XY.uss") in one USS
    Pro: The selectors are recognized and used in the UXMLs as specified
    Contra: The additional selectors are not shown in the UIBuilder and therefore debugging is very speculative.

    Maybe someone has better ideas or hints on how to handle this reliably? That would be great!
     
    Last edited: Aug 10, 2023
    kayy likes this.
  2. cax-festenberg

    cax-festenberg

    Joined:
    Aug 10, 2023
    Posts:
    5
    PS: Somehow nested USS files seem to be considered in UIBuilder (2023.1), but most of them don't work as specified:
    a) The UIBuilder function "Set as active USS" doesn't do anything detectable except for changing the font of the "active" USS (e.g. no read-only states of any USS as specified here: https://docs.unity3d.com/2023.1/Documentation/Manual/UIB-styling-ui-using-uss-selectors.html).
    SetActive.png

    b) It is possible to create an USS hierearchy in the UIBuilder-UI by drag and drop:
    USSHierarchy.png
    When trying to save it the hierarchy will be flat again:
    USSHierarchy2.png

    So anybody here can shed some light on this? Maybe there's some hope in sight in a future release? Should these posts eventually go to the issue tracker?
     
  3. cax-festenberg

    cax-festenberg

    Joined:
    Aug 10, 2023
    Posts:
    5
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    This isn't the forum for the UIToolkit which is likely why nobody is replying. Please look at the available forums before posting.

    I'll move your post to the UIToolkit sub-forum for you.

    Thanks.
     
  5. cpalma-unity

    cpalma-unity

    Unity Technologies

    Joined:
    Nov 30, 2020
    Posts:
    90
    Hello!
    We are currently working on optimizations for the UI Builder to provide a smoother experience. Some of them are already available in our alpha (2023.3). As for the bugs part, we do work on the issues reported to us, so if you encounter any issues don't hesitate to report a bug so we can look into those. The issue you are having with the saving looks indeed like a bug, but unfortunately I can't reproduce it. Could you log a bug so we can look into it?

    The drag and drop behavior for uss files also looks like a bug. I believe you shouldn't be able to nest uss files in the UI Builder, so that's why it doesn't work as you would expect. I'll open a bug for this and I'll post the case number.

    As for your use case, I can see how it's a limitation that you cannot edit selectors when they are in a tss file or in an imported stylesheet in a uss file. I'll bring this up to the team to see what kind of solutions we can provide.

    Thank you!
     
    MelvMay likes this.
  6. cax-festenberg

    cax-festenberg

    Joined:
    Aug 10, 2023
    Posts:
    5
    Thank you very much, we actually did try to find an appriopriate place to post, so your reply and action is very much appreciated!
     
    MelvMay likes this.
  7. cax-festenberg

    cax-festenberg

    Joined:
    Aug 10, 2023
    Posts:
    5
    Thank you for your hints. In general we consider UIToolkit the best UI variant for Unity availabe so far, so we are looking forward to further updates for UIToolkit!

    Regarding the bug you couldn't reproduce (Saving UXML in UIBuilder): Good news, this one is fixed in 2023.x. It was only there in 2022.x. Specifically Ctrl-S was effective if and only if the UIBuilder's viewport window was in focus.
    The fix came with a (tiny) price, however: Ctrl+S now saves the full scene, and not only those changes done in UIBuilder, as before. But we can handle that now as we know that Ctrl+S doesn't revert changes anymore if the focus is gone.