Calling functions via buttons when cooldown finished
How do I call a function when a cooldown (let's say 30seconds) it's finished?
What I do want to do is that when you press the button , Image.Fillamount (of the button) starts filling , when finished calls a function.
But I want to do that via button not via script. (after a lot of buttons it's way to confusing)
What I mean is that you have to set the cooldown from the button not from the script.
Answer by ShadyProductions · Jan 03, 2016 at 10:06 PM
You can call the wait function on the button's OnClick() I believe.
IEnumerator wait(float time) {
yield return new WaitForSeconds(time);
}
wait(30f);
public function ActionTime (actionTime : float)
{
}
public function CooldownImage (imageForCooldown : Image)
{
}
public function Cooldown ()
{
while (actionTime < actionTime)
{
actionTime += Time.deltaTime;
imageForCooldown.fillAmount=actionTime/actionTime;
yield;
}
}
I cannot call variables from functions... (what I want to do is set all these variables from the button but I cannot call them in another functions)
I don't understand what you are trying to say? Which variables do you want to set on the button? and what do you mean with 'I cannot call them in other functions'?
function CooldownImage (imageForCooldown : Image)
I want to be able to use imageForCooldown in another function but it doesn't work...
imageForCooldown can be set from a button.
Your answer
Follow this Question
Related Questions
Unity Broken Buttons 0 Answers
how to make one button disappear if i click another button unity 1 Answer
Button inside a window not responding! 1 Answer
Assign action to UI button 0 Answers
Quiz Game - Change Button text etc 0 Answers