Search Unity

Resolved Official Recommendation - Unity UI vs UI Toolkit?

Discussion in 'UI Toolkit' started by CodeMonkeyYT, Aug 26, 2022.

  1. CodeMonkeyYT

    CodeMonkeyYT

    Joined:
    Dec 22, 2014
    Posts:
    125
    Hey everyone!

    For anyone starting a new Unity project today, what is the recommendation from the official Unity team?
    Go with UI Toolkit and don't touch Unity UI?
    Use Unity UI for some specific things and UI Toolkit for some other specific things? What scenarios would you recommend one or the other?

    Or perhaps the recommendation is based on team size?
    I've only used UI Toolkit a little bit but from what I've seen one of the big benefits is splitting structure-logic-visual so you can have a programmer, UI designer and artist all working on the same UI element without any conflicts. Based on that it seems like an excellent tool for big teams where each person does a different task, but what about a solo dev?

    Thanks!
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,058
  3. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    Also not unity staff, but having recently tried to implement a runtime UI in UI Toolkit, I don’t think it’s even close to ready for runtime use, especially if you care about being able to style it or use a game controller. I tried to implement the same basic settings menu in uGUI and UIToolkit, so it was an apples to apples comparison.
     
  4. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Hi CodeMonkey, that's a great question, which is hard to answer concisely but I'll do my best :)

    In our UI comparaison page that DevDunk shared (thanks for that!), there's a section for both Runtime and Editor that summaries the high level use cases where one or the other should be considered.

    Of course the decision is often much more complex than that, but it should help you quickly assess if it's a good fit or not. I'd say in most cases, if you have hard requirements such as having UI rendered in world space, or need full customization over the shader, then go with UGUI, otherwise UI Toolkit should probably work best for you.

    The example you give is a good one. Collaboration should be much smoother, especially at scale, and authoring workflows are generally more familiar and accessible to artists and designers. Another good use case is if your game requires a lot of complexity UI, containing lists and tables of data, often found in sports simulation games or builders, you'll have a much easier time with UI Toolkit.

    And you can use both UGUI and UI Toolkit in the same project, sharing Sprites and Font Assets, so you could see a use case where menus are done using UI Toolkit and HUD containing advanced visual styles made with UGUI.

    Hope this helps!
     
    DevDunk likes this.
  5. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Thanks for your feedback bfoddy. Would you mind expanding a bit on it?
     
  6. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    > I don’t think it’s even close to ready for runtime use

    I don't agree. It depends on your needs. If all you need is a basic UI with some interaction, UIToolkit can do it.

    However, I don't see how UIToolkit would integrate with the physics system and other components. If you need this (physics, colliders) or some of its unfinished features (e.g. shaders, see the linked comparison above), you should stay with uGUI.

    > if you care about being able to style it

    The stylesheets are exactly for this. Changing style is a matter of loading different stylesheets.
    You can even use variables in stylesheets and only overwrite these to apply different colors, sizes, etc.

    > or use a game controller

    From my experience, the default controller navigation is just as bad as it was with uGUI.
    I agree, you need to implement a better default controller navigation.
    I came up with my own solution, but it isn't great either.

    I think, default controller navigation needs to consider the hierarchy of the elements.
    Further, one could use USS classes or attributes in UXML to opt-in / opt-out as a navigation target.
    Next / previous VisualElement when navigating in a certain direction could also be specified as attribute, e.g. next-component-up="#the-component-id"
     
  7. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    As I understand if we need to have UI effects particles etc that UI Toolkit is no way and we need to stick to uGui right?
     
  8. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    Is there no way to render a particle system in front of a UIDocument?
    I think it may require UIDocuments in 3D space, which is not supported yet?
     
  9. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Maybe my question is
    can we in URP draw all or part of UI Documents in some render feature and then all other render features?

    In another worlds can we draw UIDocuments not by magic in not controlled order but controlled order by URP default feature RenderFeature?
     
  10. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    245
    I guess another thing to consider is third-party plugins/utilities, shared knowledge, etc. I haven't used UI Toolkit apart from some simple tests a long time ago, but I assume that for now there are more resources for uGUI, right?
     
  11. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    Sure. For example, check this thread I made where I attempt to change the font in a drop down menu for a runtime UI.
     
  12. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Yes that's a very good point. For a newcomer, it will be easier to learn UGUI based on existing learning material, samples, Asset Store extensions and overall community having a good understanding of the feature set.
     
    DevDunk and WebMonkey741 like this.
  13. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    to close the loop on this, Etienne at Unity says in this thread:

    So I guess the 'official recommendation' is use uGUI for runtime UI.