Switch GUIBox for another after few seconds

How about, I’m trying to create a GUI Box to start with a message and switch to another after a few seconds, I have tried this script but it only shows the first GUI Box, can you help me please?

var Greeting : boolean;
var color : Color;
var Protocol : boolean;
  
function Start()
{
    ShowGreetings();
}
 
function OnGUI()
{
    if (Greeting)
    {
        GUI.color = color;
        GUI.skin.box.fontSize=18;
        GUI.Box (Rect (Screen.width / 6 - 50, Screen.height / 2 - 200, 250, 100), "<color=#00ffffff>Abrir vía aérea,

Respiración");
}
}

function ShowGreetings()
{
    Greeting = true;
    color = Color.blue;
    yield WaitForSeconds(10);
    while (color.a > 0)
    {
        color.a -= Time.deltaTime/3;
        yield;
    }
    Greeting = false;
    
    yield WaitForSeconds(2);
    
     ShowProtocols();
}
 
{
    if (Protocol)
    {
        GUI.color = color;
        GUI.skin.box.fontSize=18;
        GUI.Box (Rect (Screen.width / 6 - 50, Screen.height / 2 - 200, 250, 100), "<color=#00ffffff>Cánula,

Oxígeno");
}
}

function ShowProtocols()
{
    Protocol = true;
    color = Color.blue;
    yield WaitForSeconds(10);
    while (color.a > 0)
    {
        color.a -= Time.deltaTime/3;
        yield;
    }
    Protocol = false;
}

1 Answer

1

var Greeting : boolean;
var color : Color;
var Protocol : boolean;

function Start()
{
    ShowGreetings();
}
 
function OnGUI()
{
    if (Greeting)
    {
        GUI.color = color;
        GUI.skin.box.fontSize=18;
        GUI.Box (Rect (Screen.width / 6 - 50, Screen.height / 2 - 200, 250, 100), "<color=#00ffffff>Abrir vía aérea,

Respiración");
}

    if (Protocol)
    {
        GUI.color = color;
        GUI.skin.box.fontSize=18;
        GUI.Box (Rect (Screen.width / 6 - 50, Screen.height / 2 - 200, 250, 100), "<color=#00ffffff>Cánula,

Oxígeno");
}
}

function ShowGreetings()
{
    Greeting = true;
    color = Color.blue;
    yield WaitForSeconds(10);
    while (color.a > 0)
    {
        color.a -= Time.deltaTime/3;
        yield;
    }
    yield WaitForSeconds(2);
   
		Greeting = false;
    ShowProtocols();
}
 
function ShowProtocols()
{
    Protocol = true;
    color = Color.blue;
    yield WaitForSeconds(10);
    while (color.a > 0)
    {
        color.a -= Time.deltaTime/3;
        yield;
    }
    Protocol = false;
}

Tank you very much Landern, it works!