- Home /
Is there anyway to consume events so OnMouse events don't fire on objects with lower Z?
I have OnMouseAsButton defined on an object so that it fires when I click on it. However, I would like to block this behavior when another object is in front of it. I know you can eat the event with normal Event.current handling code, I was wondering if there is a way to do this with OnMouse events on Monobehavior.
Answer by TheVectorHunter · Aug 13, 2012 at 02:54 AM
You can do a raycast from the object that fires to it's forward position, and if the ray collides with something then don't allow your behavior to execute.
Your answer
Follow this Question
Related Questions
Does calling Destroy() on a GameObject/MonoBehavior drop references to any event listeners? 1 Answer
Events fired from Notification Center or Task Manager opening? 0 Answers
Do I have to use onPause/onStart/onDestroy 1 Answer
Call AddListener on sibling components from MonoBehaviour.Reset 0 Answers
Can a function derived from MonoBehavior subscribe to a static delegate? 1 Answer