I'm trying to make a UI cooldown button, but it doesn't show again when the cooldown is over.

if (Input.GetMouseButtonDown(1))
{
if (Time.time >= nextFireTime)
{
FireBig();
nextFireTime = Time.time + cdTime;
cdVisual.enabled = true;
}
else
{
cdVisual.enabled = true;
}
}`

Hello, maybe try using this:

GetComponent<Image>().color = your color here;

so you can do:

if (Time.time < nextFireTime) { **cdVisual.GetComponent<Image>().color** = new Color32(120, 21, 21, 255); } if (Input.GetMouseButtonDown(0)) { Fire(); } if (Input.GetMouseButtonDown(1)) { if (Time.time >= nextFireTime) { FireBig(); nextFireTime = Time.time + cdTime; c**dVisual.GetComponent<Image>().color** = new Color32(202, 24, 24, 255); } }

I placed what i modified in bold for you!

  • note : did not test it myself, but give it a try!
  • another note (surprise!) : can also try GetComponent().color