BarrierObject cooldown
We will implement the cooldown system that will deactivate the BarrierObject button as shown in the following screenshot:
Then, we will make the barrier's apparition smoother by tweening its scale.
Cooldown implementation
In order to implement the required cooldown, we need to open the BarrierObjectController.cs
script and add the following two necessary variables with an initialization on Awake()
:
//We will need the Button and the Label private UIButton button; private UILabel label; void Awake() { //Get necessary components at Awake button = GetComponentInChildren<UIButton>(); label = GetComponentInChildren<UILabel>(); }
Now that we have the button and label, we can add a Cooldown()
coroutine that will deactivate the button and update the label to show the remaining time to the player:
public IEnumerator Cooldown(int cooldown) { //Deactivate the Barrier button and update Color to Disable button.isEnabled = false; button.UpdateColor(false, true...