Simple script, however even though the bool returns back to false when the gui dissapears at after 3 seconds… it takes about 3 seconds after that until I can do it again.
‘yield return null’ let’s me do it instantly, so I’m thinking the waitforseconds is afecting the functions length, then the time after.
At least it’s what it looks like. But I can’t think of how to get around it !
Thanks,
bool showFollow = false;
void OnGUI(){
GUI.Label (new Rect (10, 10, 100, 20), showFollow.ToString ());
if (showFollow == true) {
StartCoroutine ("FadeInFollow");
}
}
IEnumerator FadeInFollow() {
GUI.skin = commandSkin;
GUI.Button (new Rect (150, 50, 128, 128), "Follow");
yield return new WaitForSeconds(3f);
showFollow = false;
}
void Update(){
if (Input.GetKeyUp (KeyCode.UpArrow)) {
showFollow = true;
}
}