I’m bumping into some issues just with keeping my project organization in order.
Any moderately complicated UI elements end up needing 3 different files:
The Visual Tree Asset / uxml
The USS file (because you cant inline things like “children of the list need to be a 20% width”)
Some C# file extending VisualElement to stick into the UXML file to add any logic
I find this really tends to pollute the project, especially since all 3 of these files generally want to have the same name but with a different file ending as they are essentially 100% coupled.
For a concrete example, lets look at a mouse over tooltip for an Item in an RPG:
You probably want to use the tooltip by referencing an Item ScriptableObject, so you need a VisualElement file to map the SO to the labels in the UXML, you’ll have to pop this into the UXM. This file will never be used for any other UI Documents, but it will always add clutter in the Editor as a custom control.
The list of item stats is probably not going to be uniform, so you’re going to need to be able to handle 0-n stats on the item. Making sure all the labels format correctly in the stat list will likely end up needing a “#list > Label” selector, so we cant do that inline & will have to make a USS file.
In this example we have 3 files, probably ItemTooltip.uss, ItemTooltip.cs, and ItemTooltip.uxml
All of them entirely coupled with the other, and now if we have a folder with game UI elements, every one is going to be 1-3files of the same name which really makes navigating the folder more frustrating when you end up with 20+ unique elements.
Is there a better way I could be organizing the UI elements? I mostly cobbled this setup together from the Example Clash Royle Clone project, and it seems messy.