Hi,
I am trying to design an UI for runtime use.
When creating an uxml, how do I make properties from inside the uxml to be changeable in places where I want to use the uxml?
Also, how do I add elements to containers inside an uxml? The childs seem to be read-only in the builder.
Hi,
For your first question, please have a look at this thread. It shows how to instantiate uxml files and modify element properties such as button text: How to Make an Item in a ListView from a uxml template?
About your second question: you should be able to simply drag and drop UI Elements as children of a VisualElement container using UI Builder. Is is what you’re trying to achieve? If not, could you provide further details please?
Regards,
Alain
I am trying to gauge the possibilities in UI Toolkit to create common controls and reusable parts of the UI. I managed so far to include other UXML files inside of others. One video referred to it as similar to “nested prefabs”. In the sample project from Unity, for example, the main menu is composed of 3 UXML for the options, the credits and the actual game UI.
However, without the ability to customize the dragged-in UXML files, I find this feature rather limiting.
For example, lets say I have an game with several UI’s that display detail information of things you can click in the world. There are lots of different categories like buildings, units, spells, items, buffs, whatever. Allthough they have some common things like a name, many of their properties are different. Now lets say I want to create some commonly used UXML sub-parts for things like the “Header label plus some type label, plus the close-button plus tooltips for them plus a frame plus some common buttons on the button”. These should be the same for all (or many) of the different types. There would be an area in the middle where the differences are. Lets call this “CommonDetailPanelParts.uxml”
How would I expose properties like the text on the type label, so I can customize it depending on the place where I use it?
How would I add childs to the area in the middle? It is an Visual Element inside the CommonDetailPanelParts.uxml, but when I drag that CommonDetailPanelParts.uxml into, lets say “UnitDetails.uxml”, then all interiour becomes read-only.