every rpg game has skills and when u click on them then there is a cooldown time where you cant click on the button again im trying to make that in unity but its not working i dont want to use WaitForSeconds becuase that dosent work if i use that then the button wount show up any help plizz
Here’s a solution using a counter :
var myCounter : float = 0.0;
var mySetTime : float = 2.5;
function OnGUI () {
// when my set time is reached
if (myCounter >= mySetTime) {
// show GUI Button
if (GUI.Button(Rect(10, 10, 100, 35), "Start Again")) {
myCounter = 0.0;
}
}
// add time to counter
// use myCounter++; (same as myCounter+=1;) to count the frames - or
myCounter += Time.deltaTime; //
// display counter
GUI.TextField (Rect((Screen.width/2)-100, 10, 200, 25), "myCounter : " + myCounter);
GUI.TextField (Rect((Screen.width/2)-100, 40, 200, 25), "mySetTime : " + mySetTime + "secs");
}
Here is some psuedocode because I don’t have much experience with GUIButtons that might work:
var buttonClicked = false;
function OnButtonClick() //DON'T KNOW IF THIS FUNCTION EXISTS
{
if(buttonClicked == false)
{
buttonClicked = true;
//CARRY OUT BUTTON STUFFS HERE
yield WaitForSeconds(1.0); //CHANGE THIS TO THE NUMBER OF SECONDS YOU WANT TO WAIT FOR
buttonClicked = false;
}
}