- Home /
Block Scene objects click through UI
Good day Is there a easy way in Unity4.6 to block clicking or any other mouse activity if cursor position is over the UI element? I dont want to interact with any object on workign area if working on UI
Answer by Kiwasi · Dec 22, 2014 at 10:39 AM
Another alternative is to use the event system to process all of your clicks with a physics raycaster. Clicks will automatically get prioritised.
Edit: Adding a YouTube video, since this has been asked a few times
I got EventSystem in my project, but I cant find any possibility to process click to physical raycast. I thought about it, when found an option on Canvas Group component.. Can you explain it please?
hi, looks nice but I'm confused, what if i have a Gamemanager that handle a start game click (basicly any key on any spot on the screen). where do i need to implement the interface then (i've tried to implement it on that Game$$anonymous$$anager but no luck, the OnClick function doesnt fire at all). thanks in advanced
Answer by martin101 · Dec 22, 2014 at 10:23 AM
How do I stop clicks/touches on the UI from 'going through it' and being clicks in my game world?
Use EventSystem.current.IsPointerOverGameObject() to check whether the mouse is over a GUI element before you process your game world clicks. See this post for an example. Also, on mobile, you may need to specify which finger you're asking about - see this thread for details.
Answer by LRG · Dec 22, 2014 at 10:15 AM
From the forums:
How do I stop clicks/touches on the UI from 'going through it' and being clicks in my game world?
Use EventSystem.current.IsPointerOverGameObject() to check whether the mouse is over a GUI element before you process your game world clicks. See this post for an example. Also, on mobile, you may need to specify which finger you're asking about - see this thread for details.
There might be a new better way, though.