We would like both our power sources to be switchable between these four elements:
Fire
Water
Ice
Lightning
In order to do that, we'll give the player the possibility to display the following selection menu when he or she right-clicks on a power source:
Before we implement the code to display it, we'll create the necessary buttons.
We'll build the elemental switch UI as seen in the previous screenshot. We first create the Fire elemental button and make it a prefab in order to create the other three other buttons.
Let's start by creating the Fire elemental button:
Create a new empty GameObject with Alt + Shift + N.
Rename it to
ElementSwitch
.In the Project view, type in
button
in the search box.Drag the
Control – Simple Button
prefab into our newElementSwitch
GameObject.Rename our new button to
ElementalButton
.Reset the Transform position to {
0
,0
,0
}.
OK, let's select and configure this button...