I’m writing a node-based editor. This is the first time I interact heavily with Unity’s GUI events. I’m confused about the ‘Use’ method. The doc says:
Call this method when you’ve used an
event. The event’s type will be set to
EventType.Used, causing other GUI
elements to ignore it.
While other links explain it as ‘it makes the event get eaten’
I appreciate the doc effort doing such an amazing job to explain it thoroughly like that but I’m afraid my mind is too thick.
First of all “Call this method when you’ve used an event” - what does “you’ve used an event” mean, and when does that happen?
Usually, you get the current event and use it to query things, i.e.
var e = Event.current;
if (e.type == EventType.MouseDown && e.button == 0)
// do LMB stuff
else if (e.type == EventType.KeyDown && etc)
// do more stuff
Does that count as “me using the event”?
Another example, moving a window rect with mouse:
if (e.type == EventType.MouseDrag && rect.Contains(e.mousePosition))
{
rect.x += e.delta.x;
rect.y += e.delta.y;
}
How about that? does that require ‘Use’?
Can somebody please explain to me any of the following:
- What does ‘Use’ actually do?
- When and why would I consider calling it?
Any help is much appreciated, thanks for your help and generosity reading my question in advance
Note: Please don’t mention anything about ‘eating’ events, nor calling ‘Use’ when I ‘used the event’, I’ll happily downvote and delete your answer on the spot j/k