I was wondering how I would work out the following situation: I have an NPC that generates a GUI depending on a particular variable. However, the following code generates both GUI’s rendering at the same time… by both I mean: there’s one that should appear when the variable no_coop_button is set to true and another to appear when the npc_trigger is set to true. I’m not sure how to generate these GUI’s separately.
function OnGUI()
{
if (no_coop_button)
{
GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
GUI.Box (Rect(0, 0, 100, 100), "You are \n a thief");
GUI.EndGroup ();
}
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 \n treasure \n chest");
Destroy(this, 5.0f);
}
else if (nobutton)
{
GUI.Box (Rect(0, 0, 100, 100), "You \n cannot \n enter");
Destroy(this, 5.0f);
}
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 ();
}