- Home /
Is there anyway to stop event propagation
Hi,
I have a pause button while playing game, so my player has behavior to move wherever touched. So when pause button clicked , player moves towards pause button.
Tried OnPointerClicked Interface on pause button but not working.
Current workaround is when player moves i set pause (image) raycast to false and using if(EventSystem.current.IsPointerOverGameObject()) return in Fixed Update Input.touchCount of Player
But it is making things clunky as player has to move continuously.
Is there any method like event.stopPropagation() or some thing similar? Thanks in Advance!
Is the Pause button a gui element, or something in your game's world?
Regardless, I imagine you're doing some sort of raycast with the camera to deter$$anonymous$$e where your character should be moving.
Yes pause button is a GUI element, and i am using simple Input.gettouch(0).position to move player and on Pause button i am using OnClick.
Looks like there's no event propagation, because the GUI event and your code execution are seperate events. What I think you can do is reading EventSystem.current.alreadySelecting variable prior to your Input.gettouch(0).position. If it's true just return. $$anonymous$$aybe that work's
Answer by Ponytech · Jan 26, 2017 at 09:55 AM
Working solution here : http://stackoverflow.com/questions/35529940/how-to-make-gameplay-ignore-clicks-on-ui-button-in-unity3d
Your answer
