Search Unity

UIBuilder Questions

Discussion in 'UI Toolkit' started by Adrian-Anta, Oct 31, 2019.

  1. Adrian-Anta

    Adrian-Anta

    Joined:
    Oct 26, 2012
    Posts:
    35
    Hi,
    • I heard that the plan is to stop saving uss and uxml files in pairs in the future, but would that mean that while I'm working on a .uxml hierarchy I could search for any .uss available within the project, not just within that particular UIDocument? The use case I'm looking for is that I have one uss for all buttons in the application, and those buttons are spread between several uxml files. I think this is not currently possible? Correct me if I'm wrong.
    • I can't parent anything to a custom UIDocument dragged from the library to the hierarchy panel. It shows up as greyed out. I'm wondering what I have to do for them to behave as the Unity prebuilt controls, where I can add children to it without problems.
    Thanks.
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    • Yes, the UI Builder will learn to deal with multiple (or zero) USS files per UXML. This will enable you to share USS files across many UXML files, as you can already do when writing UXML manually. But also yes, this is not currently possible when just using the UI Builder.
    • It should be possible to parent elements under UXML template instances (I assume that's what you mean by UIDocument?), but only at the end. But this is not really encouraged in general. Even for default Unity controls, like IntegerField, it doesn't make much sense to parent elements inside the IntegerField. Some elements do actively support this, like Foldout, where they define a special inner element to act as the "container" for all children.
      In either case, the insides are grayed out because the entire subtree is an instance of another UXML document (or custom C# element) so it's not editable. You have to open for editing that UXML document if you want to change the internal hierarchy. We have plans to make this switch easier and more in context in the future.
     
  3. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Are there plans to make Template overrides easier/possible to use? I can't seem to find any means to override instances and add additional styles to existing elements.
     
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    There is a specific feature in UXML for overriding attributes of elements inside a UXML template from the main UXML doc. This uses <AttributeOverrides> tag. This feature is not yet supported in the UI Builder but should be eventually.

    However, styles can easily be overriden. You should be able to inspect elements inside a UXML template instance in the UI Builder and find out what style classes they have. Using these classes (and names if necessary), you can create USS selectors that match these classes and override the styles of elements inside the template instance.
     
    StephanieRowlinson and recursive like this.
  5. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Thanks!