Saving UI Builder

It took me a while to find the Save so may be worth putting it in somewhere @garypettie (you look like you saved between 'Structure and Style And USS Box Model).

To save - Viewport, File (Top Left Corner), Save (As)

Hey @EddieRocks, I hope you’re enjoying the short course so far!

I cover the file menu at around 3:15 in this lecture.
Personally, I just have a reflexive habit of hitting ctrl+S whenever I make a change I want to keep. This saves everything in Unity (including all your scene stuff) so it’s less selective than going through the UIBuilder’s file menu but it gets the job done! :smiley:

OK - cool - Missed that… as didnt need to do it till later it passed me by.

Ctr+S is interesting as that is what I usually do.
I tried again starting a new Builder file and Ctr+S brought up the save the first time I used it but if I cancel out of it then Ctrl+S didnt work for me subsequent times. Wonder if its a bug or just me?

The course is good so far.

I didnt know this area existed in Unity and had assumed the course was expanding on the old ways of building editor extensions where my knowledge is limited.

From the looks of it it can be used for UI in Games as well as Editior extensions

Just finished Basics so hopefully the next sections will have some real application examples.

the UIToolkit started getting added to Unity 2020 with the intention of completely replacing the old IMGUI system (only really used for editors these days) and the current in-game UI system.

You originally had the option to add UIBuilder as a package from the Unity repo, or you could just code up the c#, uss, and uxml manually for editor scripts (which is what a a lot of the current editor tutorials and resources lean towards).

The UIBuilder was then added directly into Unity in 2021. The editor stuff is now mostly stable and they are working on all the in-game UI stuff (which will still have some overlap with editor scripting). It’s still a little unstable on that side of things though, so expect some changes to be made over the next few versions.

In the next section we create a simple “task list” editor window that has some utility for any project you work on going forward and will show you how to work with some of the more common elements.
Brian is also looking at updating his blog series on creating an “InventoryItem Editor” for the RPG course, using the new UIToolkit.

Looks like we can get Tag, Layer and Mask dropdowns too.
Are these going to be easy to use in a GameObject components SerailisedField vars or is using Odin and/or NaughtyAttributes asset packs going to be still the way to go to avoid hardcoding tags or layer names which I loathe…

I’ve not played around with these directly but I’d imagine they’re pretty simple. Looking at the sample code for those elements (check Window > UI Toolkit > Samples) they don’t look particularly hard to use and once this course is finished you should have all the knowledge you need to get started.

Ctrl+S seems to work if you are ‘in’ the UIBuilder panel. If you have clicked away to the Hierarchy or the Project panels for example then Ctrl+S doesnt save the UIBuild…

Interesting, I don’t think I ever noticed. That’s good to know! :smiley:
I hope that they will add an autosave option at some point, like they have with a lot of their other new tools (Shader Graph, Input System, etc). It would definitely make life a lot easier.

The Tag and Layer fields are specialty EnumFields that Unity will populate with all of your tags. Of course, there isn’t a nice friendly enum for a tag, though LayerMasks are something already supported by Unity. For a layer, just serialize the LayerMask and use the LayerDropdown in your custom editor. For Tags, serialize a string for the tag, then in the Editor, set the TagField.Value to your string, and in your custom (evt)=>{}; closure or set method, set the serialized string to evt.newValue.

If you were refering to ObjectFields picking up MonoBehavior based classes, sadly, this is still a no-go. The ObjectField behaves exactly like EditorGUILayout.ObjectField, meaning it won’t, for example, give you a list of all Prefabs containing a Pickup component (to use an RPG class as an example). I’ve written a pretty nice workaround for this, which will be in the InventoryItemEditor tutorial.

I actually use an AutoSave utility in my projects which always saves the current scene before Play, saves the current scene in preset time intervals, as well as the project itself. Sadly, it doesn’t seem to notice ShaderGraphs or the UIElements editor. It also doesn’t notice Prefab editing mode, but that’s a good thing. Prefab editing should always be done with Save OFF, especially if you’re working on IMGUI elements. Only Save your Prefab when you’re ready.

Privacy & Terms