Hi!
I have a script attached to my GUITexture that appears a few seconds into my game, and disappears again in 5 seconds.
I was wondering if there is a way to pause the game while this GUI is displayed? It would make the game run a whole lot better.
Thanks in advance.
John
public class TestScript : MonoBehaviour {
private GUITexture myGUITexture;
[SerializeField]
private float delaySeconds = 1.0f;
[SerializeField]
private float showForSeconds = 1.0f;
void Awake() {
myGUITexture = GetComponent<GUITexture>();
}
void Start() {
ShowImage();
}
public void ShowImage() {
StartCoroutine(ShowImageTimed(delaySeconds, showForSeconds));
}
IEnumerator ShowImageTimed(float startDelaySeconds, float showForSeconds) {
Debug.Log("In coroutine.");
yield return new WaitForSeconds(startDelaySeconds);
Debug.Log("Enabled texture.");
myGUITexture.enabled = true;
yield return new WaitForSeconds(showForSeconds);
Debug.Log("Disabling texture.");
myGUITexture.enabled = false;
}
}