For the past 2 weeks we’ve been implementing the UI.

Here it is.

I’m breaking this up into multiple parts: Build Menu, Object Windows, and HUD. I’m only going to talk about the Build Menu in this post. Next week I’ll talk about Object Windows and possibly the HUD (depending on how long the post becomes).





Positioning Elements

Placing buttons, images, and text into the proper location is probably the most fundamental part of a UI.

Categories

The entire UI is composed of “categories”. A category is essentially a hierarchy that describes where a UI element should be placed. An example category might be:

Build Menu > Summary > Palette

This would instruct a new element to be placed on the palette area of the summary area of the build menu.

I’m just going to call these “slots” from now on. So I’ll say, “the button is looking for its slot at ‘Build Menu > Summary > Palette’.

Slots Everywhere

Every single Unity GameObject can potentially become a UI slot. When the game first starts, there is only a single UI slot: Game Menu. All other slots are created at runtime as UI objects are placed.

For example, the toolbar is placed when the game first starts. It looks for the Game Menu slot. Once placed, the toolbar becomes a new UI slot: Game Menu > Toolbar. Toolbar buttons are then placed, and they look for Game Menu > Toolbar.

Here’s a gif to show you. There’s not much context, so let me try to explain it.