Hello, I am starting to use the UI Toolkit to do an interface for my non-game unity app. How can I simulate a menu bar?
I watched this example from old Unity UI but I don’t know if I can do this on the new UI system as there are no panels.
Thanks!
When you need a panel use a VisualElement instead. It’s a container and you can drop items that will align horizontally or vertically depending on the flex settings.
Thanks for your answers!
I will try all you have said and post any results.
The problem I am encountering is: with the old UI system I can have panels like “windows”, for example, when I click a button, a panel appears over my main panel (like a floating window). With this UI system I don’t know if this is possible because when I add a visual element it is added inside the current hirearchy, so, if I want to add a visual element just in the middle of the screen that will appear when a button is clicked, this visual element is automatically added as a child of the visual element under it. So what I think I need is to have multiple roots visual elements at the same time so none of them depends on each other and I can overlay one over another. Is this possible? Maybe the solution is not having multiple root visual elements and there is other approach.
Thanks!
There are two approaches with UI Toolkit. One is to make the element beforehand then hide it with either display none or visibility hidden, and of course you make it appear when the button is clicked. The other way is to instantiate a visualtree that you will attach to one of your visual elements. Since you just begin I suggest you try the first one and you can use the other later once you understand how to instantiate visualtrees.
Ok, thanks! I will try the first suggestion and see if I achieve what I want.