- Home /
Can I use EventSystems to receive PointerEvents anywhere on screen?
I'd like to use the EventSystems class to receive mouseclick or touch events and get information such as position from them without the need for a button object in my scene.
I know how to implement IPointerDownHandler etc. on a custom button, but how would I do the same thing to receive a pointer event anywhere on the screen?
Basically, I'm looking for a clean system that manages touch and mouseclicks anywhere on screen and brings those different input methods together, so that I end up with a function like GetDragAmount(), which returns a drag distance for either mouse or touch drag. (I know how to write the basic functionality for everything, I just don't know how to turn it into a clean event system.)
Thanks!
Technically the answer is yes, however what are you wanting to use it for?
you could certainly put a panel on a canvas with Alpha set to zero, but there are drawbacks. If you wanted to click something behind that panel you couldn't.
So again what is it you want it for?
this comment is rather silly. there are endless examples of where you need to "detect a touch anywhere on the glass".
Generally, don't ask "why do you want to do this" questions please
For now I've been writing my own input class, which polls Input.Get$$anonymous$$ouseButton() etc and then sends my own OnPointerDown events and such whenever I click or touch. I just thought it might be possible to use the Unity EventSystem, which basically has all the event functionality I need built in, but since it needs to have an actual panel/button object in the scene I couldn't use it yet. But if there is no smart way to use it for click events anywhere on screen, I'll stick to my own version.
Your answer
Follow this Question
Related Questions
How do I stop EventSystem.currentSelectedGameObject from changing on a button press 0 Answers
How to call an implemented custom Interface 1 Answer
passing function to class 0 Answers
passing function to class 1 Answer
Multiple Cars not working 1 Answer