14: Mining for Diamonds (Part 2)
Learning Target
- Create a UI for a game in Unity that works for multiple game resolutions
- Use anchors and pivots to control the appearance of a Unity UI
Resources
Video Tutorial
Starter Icons
Instructions
Step 1:
Open your existing project from Part 1.
Add a subfolder to your Textures asset folder called UI. Here is an example with textures organized into several folders:

Step 2:
Download the starter files and unzip the archive.
Drop the files you plan to use into the Textures→UI folder.
Each of these files will need to be changed to be a Sprite.

Step 3:
When we are done we will have a few different UI parts.
Create two UI panels to organize the screen.
-
- Main UI (top or bottom)
- Selected Drill UI (side)
For example:

Step 4:
We will need to do 3 basic things with our UI:
-
- Show the values of variables
- Allow the drill to be upgraded
- Exit the program gracefully
To make life easier, I suggest using these to create a custom display:
-
- Panel
- Image
- Text
Here is an example of a money display:

Then, drag it into the Prefabs folder so you can easily reuse it by simply changing the icon image.
Step 5:
I used these things to create a combined display and upgrade display:
-
- Panel
- Image
- Text
- Button (with text element deleted)
For example:

Once again, drag it into the Prefabs folder so you can easily reuse it by simply changing the icon and button images.
Step 6:
Finish creating a main UI that contains these items:
-
- Money earned
- Number of drills owned
- Total rocks, iron, silver, gold and gems collected
- Button to close game
For example:
![]()
Step 7:
Finish creating a selection UI that contains these items:
-
- Displays for speed, power and cooling
- Buttons to upgrade speed, power and cooling
Step 8:
You could also add these to your selected drill UI to give it more realism:
-
- Rocks, iron, silver, gold and gems currently in the selected drill's hopper or dirt pile
- Current rotational speed, power in horsepower and temperature
Grading
For grades A to D, all requirements need to be met for that grade band.
| Indicators and Collectibles | Letter Grade |
|
A+ |
|
A |
|
B |
|
C |
|
D |
| Doesn't meet above criteria | Reassigned |