How can I get the last button in this code to disappear after say… 5-10 seconds? I tried yield and destroy(this), but they didn’t work:
function OnGUI()
{
if (npctrigger)
{
//GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
if (yesbutton)
{
GUI.Box (Rect(0, 0, 100, 100), "Enter treasure chest");
}
else if (nobutton)
{
GUI.Box (Rect(0, 0, 100, 100), "You cannot enter");
}
else
{
GUI.Box (Rect(0, 0, 100, 100), "Give inventory?");
if (GUI.Button (Rect(25, 25, 50, 30), "Yes"))
{
yesbutton = true;
Debug.Log("True");
}
if (GUI.Button (Rect(25, 65, 50, 30), "No"))
{
nobutton = true;
Debug.Log("No");
}
}
//GUI.EndGroup ();
}
}