It is ultra verbose so I’m thinking this can’t be it
(At the bottom)
That looks like an IMGUI how-to article, not UI Toolkit. Are you interested in knowing how write custom inspectors in UI Toolkit (instead of IMGUI)? If you were not aware, UI Toolkit is a different UI framework from IMGUI.
look at the bottom, the guy uses UIElement, which was the old name of UIT I think
I see. Ya, the namespace hasn’t changed from UIElements so all that is still valid. If you’re looking for other examples of implementing custom inspectors in UI Toolkit, there’s our docs:
And if you know IMGUI and want to switch over to UI Toolkit, this video compares the two in some detail:
Repo: GitHub - Unity-Technologies/UIElementsUniteLATurretDemo: Demo Used in Unite LA 2018 UIElements talk.
I can see the benefit from your presentation, when you add the css, the xml and the c#, is it less verbose than IMGUI?That guy’s blog, it took him 3 files and many more lines of code to describe the same thing as IMGUI. 3 files and 3 languages instead of 1.
This is not optimal.
Many of the best editor scripts I use are one file. I’m sure you can inline the xml and css as string in the c# file but then you lose all autocomplete and xml is not easy to read.
So is there a plan to add c# equivalent to xml and css? Something expressive and terse that is intellisense friendly?
UXML and USS are there to help you write less C#. I means you can express the more static parts of your UI definition in clear, purpose-made, syntax and can modify these static parts without needing to recompile C#.
That said, you are not forced to use UXML and USS. You can do everything in C#:
- UXML just calls “new VisualElement()” or “new Label()”, sets their properties, and calls
parent.Add(child)for you to create the C# objects for the elements. It’s no different than writing C# to create and parent your elements. - USS ultimately sets the
someElement.styleproperties of your elements, using a selector/query system to make it much easier to share and change styles across your entire UI
UI Toolkit was made to server the needs of complex, rich, UIs, for both initial creation AND iteration speeds - where IMGUI and uGUI started to break down. It is less focused on one-off simple UIs which is why it may seem a bit complex at first. But if you stick to just using C# and inlining all your styles, it’s not far off from IMGUI, imo.
Say no more I’m on board.
hm, can you give an example of IMGUI then UIT in pure c#?
A video showing all the different workflows to produce the same thing would be dope.
The UIT editor generates both xml/css and c#? How does it store layout and such?
Here you go:
https://www.youtube.com/watch?v=sVEmJ5-dr5E
If by “UIT editor” you mean UI Builder, then yes, it generates UXML and USS. It does not generate C# though. Builder’s job is to help you visually create the layout and styles of your UI but you still need C# to make it functional. UI Builder’s actually another reason we have UXML and USS as separate assets. We can describe at least part of the UI as pure data that can be generated by a tool, unlike having everything in C# and requiring complex code generation.