Trigger in GUI event

So my problem is that I need to detect if a key is pressed inside a trigger area, ‘hotspot’ and then do a GUI animation.

So the way I have it set up at the moment is ‘OnGUI’ because that appears to be the only way to call GUI functions, so how do I say for example: OnGUI, if keypressed and the trigger is initiated?Just seems like I am missing some fundemental information here.

function OnGUI () {
GUILayout.Label (“You are in a hotspot, Press E”);
if (Event.current.Equals (Event.KeyboardEvent (“[E]”)))
//do something here
}

Where would the trigger go?

Create a collider and scale it to what you need. Place a script on that GameObject and hook up a OnTriggerStay block above a OnGUI block and you could use a bool(eg) var showGUI : boolean; then inside the OTS function create an if statement that checks the input of a button and a bool being false( cause its default is false). Inside set the bool to true. In the OGUI function almost do the opposite
create an if condition to check if the bool is true and then set it to default false inside. any other code inside the condition will execute as well.