OK I’m not sure if this is the right place to ask this or should be asked at UnityGUI part of the forum but here goes.
Situation: I’m making a simple OnTriggerEnter, show GUI menu. i.e. if a character is within the collider space, a menu will pop-up and the player can select which part of the menu by pressing on the assigned hotkeys.
Problem: Pressing on the assigned hotkeys does not work. Nothing shows up.
Here’s my script:
private var showCounterMenu : boolean = false;
var Form1 : Texture;
var Form2 : Texture;
function OnTriggerEnter()
{
showCounterMenu = true;
GetComponent("MouseLook").enabled = !GetComponent("MouseLook").enabled;
}
function OnTriggerExit()
{
showCounterMenu = false;
GetComponent("MouseLook").enabled = true;
}
function OnGUI()
{
if(showCounterMenu == true)
{
GUILayout.BeginArea(Rect(50,50,300,300), "Counter Menu");
GUILayout.Box("Please select a form.");
if(GUILayout.Button("Form 1 (Press F1)") || Input.GetKeyDown(KeyCode.F1))
{
GUILayout.Box(Form1);
}
if(GUILayout.Button("Form 2 (Press F2)") || Input.GetKeyDown(KeyCode.F2))
{
GUILayout.Box(Form2);
}
GUILayout.EndArea();
}
}
Buttons will show, but they don’t work.