A traditional 2D UI
To start our GUI programming, we'll create some buttons, a health bar, a level counter, and an experience counter. All of these are common in a variety of video games and are key elements to game design.
Setting up our scene
Since in this part of the chapter we will be dealing with 3D space, we'll need to set up a scene to test with. We'll only need a basic test level, so create a new scene and name it Chapter 2
. Add a cube or plane for the floor, a directional light, a GameObject for our enemy, and two quads. This is what my scene looks like:
Set the two quads in the same position just above your enemy object and rotate one of them by 180 degrees so that the two quads look like one object. Drag one of the quads onto the other, making a parent-child object. Now that our scene is ready, let's get to the scripting.
Housing our 2D UI
Before we start creating our 2D UI, let's make the script to house it all. Create a new C# script and name it GUI_2D
...