Here's what I don't understand about Events:
the documentation says that Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events. For each event OnGUI is called in the scripts; so OnGUI is potentially called multiple times per frame. Event.current corresponds to "current" event inside OnGUI call.
the documentation pertaining to onGUI states that it hasone call per event
That doesn't make sense to me, because I know I can call Events within OnGUI.
I have an OnGUI function that draws a grid using x and y nested for loops, then checks using Event.current.mousePosition
if your mouse is hovering over a grid block. What I don't get is how OnGUI is ever called, if OnGUI is only called when an event occurs, but I have the event inside OnGUI so how can you ever check if the event is being called inside a script that is only called after the event is called?
I know that probably sounds confusing -- I'm just puzzled by the seemingly cyclical nature of ongui.
Event.current.mousePosition
is not triggering an event, it's accessing the event that triggered the currentOnGUI
method call.OnGUI
is called once per frame and once for every event. \$\endgroup\$Input
andEvent.current
do not overlap each other entirely. Comparing them isn't really practical. \$\endgroup\$