Hey.
I’m trying to show/hide an inventory GUI via the player pressing “i”:
var windowRect : Rect = Rect (20, 20, 220, 100);
var visible = false;
function OnGUI ()
{
if(visible)
{
windowRect = GUI.Window (0, windowRect, WindowFunction, "Inventory");
}
}
function WindowFunction (windowID : int) {
// Draw any Controls inside the window here
}
function Update()
{
if(Input.GetKey("i"))
{
visible = !visible;
}
}
function Refresh()
{
}
It works, but the window “glitches”… as if it is being shown/hidden numerous times during the key press. Why would it be doing this? How can I get around it?
Cheers.