Hello everyone,
I’m reaching out to gather some opinions and experiences regarding UI development in Unity. I love programming, but I absolutely dislike coding websites from scratch. Because of this, I’ve been quite drawn to Unity’s UI Toolkit.
I find the UI Toolkit intuitive and straightforward, which saves me from the pain of handcoding UI elements. However, I’ve noticed that it seems somewhat limited compared to writing everything myself.
For those who have experience with both methods, could you share your insights? Specifically, I’d like to know:
- What are the main advantages and disadvantages of using Unity’s UI Toolkit versus handcoding UI elements?
- Are there any significant limitations with the UI Toolkit that might affect more complex projects?
- How does the performance and flexibility of the UI Toolkit compare to a fully custom-coded UI?
- Have you encountered any specific challenges or bottlenecks when using the UI Toolkit?
I’d appreciate any advice or experiences you can share. I’m trying to decide whether to stick with the UI Toolkit or invest the extra time to handcode my UI elements.
Thank you in advance!
You’ve already given yourself the answer. 
First of all, I assume you mean “using UI Builder vs programmatically creating VisualElements”. Because UI Toolkit is the framework which provides both UI Builder and the VisualElement API.
In how far?
The main advantage is WYSIWYG. In UI Builder you instantly see what your GUI will look like, including any style modifications. If you were to program it, you’d have to enter playmode for each and every tiny little layout or style change. This alone will kill your time quite effectively.
So it’s really a matter of whether you want to waste time on “guessing it right” or “seeing what you are doing”. 
Thanks to data binding you also needn’t program dynamic elements of the GUI. This will also prevent you from having to write a lot of boilerplate code.
Compared to UGUI yes, there are some areas UITK currently doesn’t handle (as well). For instance, you cannot use UITK to create world space GUI.
And all UITK elements will be drawn in front of every other content - for example if you want a 3D preview of your character in an Inventory screen, you’d have to render that character into a RenderTexture. Although I think this is best practice even for UGUI unless you wanted the ability to have the character model break out of (draw over) the GUI container frame.
Within UITK it doesn’t matter whether the UI was loaded from UXML or whether you programmed it. Assuming the exact same layout they will perform identically.
I mean the middle ground is using UI Toolkit but coding additional functionality and custom controls as necessary. That’s been my general workflow so far, though I mostly do things via code as I just prefer the control.
I mean a custom UI framework would probably be faster if you ensure it only does as much as you need to do, or have it be hyper-optimised (something PanGUI is aiming for). But who actually has the time to do that? It’d make more sense to pick one of the existing frameworks that suits your need (UI Toolkit or otherwise), and can interoperate with Unity, and go with that.