Hi, as the title try to say, I have to change my GUI, specifically, a GUITexture, from time to time.
For example: in the first 5 seconds, I have to display the GUITexture1. After this, for another 5 seconds, I have to show the GUITexture2. I intend to display this GUITextures to make something like a “Introduction”.
So, I’ve tried to do something like this:
void OnGUI ()
{
if (messageGUI)
{
if (textOpt == "Ligado")
{
message = Resources.Load("Levels/General/generalSpeech1") as Texture;
StartCoroutine(showMessage(message, new Vector2(tabItem, Screen.height-avatarSize-2*tabItem-messageSize.y), messageSize, time));
message = Resources.Load("Levels/General/generalSpeech2") as Texture;
StartCoroutine(showMessage(message, new Vector2(tabItem, Screen.height-avatarSize-2*tabItem-messageSize.y), messageSize, time));
message = Resources.Load("Levels/General/generalSpeech3") as Texture;
StartCoroutine(showMessage(message, new Vector2(tabItem, Screen.height-avatarSize-2*tabItem-messageSize.y), messageSize, time));
}
}
}
IEnumerator showMessage (Texture message, Vector2 position, Vector2 size, float time)
{
messageGUI.enabled = true;
messageGUI.texture = message;
messageGUI.name = "Message";
messageGUI.pixelInset = new Rect(position.x, position.y, size.x, size.y);
yield return new WaitForSeconds(time);
messageGUI.enabled = false;
}
But I’ve noted that this don’t solve my problem, 'cause the OnGUI function are always running and the next command don’t wait the previous to finish before starts running. I know why, but I don’t figure out how could I do what I want.
Any ideas?
Thanks in advance.