function OnGUI()
{
if(GUI.Button(Rect(190,14,110,40), “Use Diamonds”))
{
use = true;
}
if(use)
{
GUI.Window(0, Rect((Screen.width/2)-230, (Screen.height/2)-255, 330, 260), useMagic, "Special Request");
}
//GUI.Button(Rect(300,14,110,40), "Minimap toggle");
}
function useMagic()
{
if(use)
{
print("display diamond");
GUI.Button(Rect(40,44,90,120), greenDiamond, "");
GUI.Label (Rect (100, 44, 300, 60), " X " + collectgreenDiamond);
GUI.Button(Rect(40,104,100,120), purpleDiamond, "");
GUI.Label (Rect (100, 104, 300, 60), " X " + collectpurpleDiamond);
}
// You may put a button to close the pop up too
if (GUI.Button(Rect(40, 180, 75, 30), "Close"))
{
use = false;
}
}
Anyone can tell me what wrong with the code snippet?? When i click on use diamond, it is not displaying the window?? I can’t seem to see anything wrong…
*EDIT: i have update my code snippet. Now the window is display but another thing that make me headache is. HOw come the window is not closed?? what wrong??
You cannot use GUI outside of the OnGUI() function. Put your "close" GUI inside the same "if" statement as the window.
– You@You You are suppose to be able to have GUI inside of the windows...if you take a glance at the reference
– hijinxbassist