The PowerSource
component already has the required code to switch from one element to another. Let's link UI elements to it in order to give feedback to the player. We'll first add a progress slider to indicate how long the elemental switch process takes.
Let's create the Progress
prefab, which will be a slider to indicate any kind of progress in the game—in this case, the elemental switch's duration, which will look like this:
Follow these steps to create our Progress
prefab:
In the Project view, enter
progress
in the search field.Drag
Control - Simple Progress Bar
into ourInGame2DUI
.Rename this new instance to
Progress
.For its attached
UISprite
component:Change Size to
400 x 35
Set its Color Tint to {R:
180
, G:180
, B:180
, A:220
}
For its attached UISlider component:
Set Value to
0
Select its
Foreground
child GameObject, and for its UISprite:Set Color Tint to {R:
255
, G:230
, B:200
, A:255
}