- Home /
How to add onPointerDown event on SpritRenderer GameObject
I need to add onPOinterDown event to a spritrenderer .
Its work properly on ui game object (like image , text etc.)
But i need to it for spritRenderer (for non ui game object)
Check out On$$anonymous$$ouse* ( Down / Up /...) messages for monobehaviours.
Answer by tormentoarmagedoom · May 08, 2018 at 03:08 PM
If i remeber well... you can add a collider to that object, and use
void OnMouseOver()
That will be executed once the mouse is over the object. And
void OnMouseExit()
you knwo wht does :D
Bye!
You can do it that way but I have read about problems from doing it by On$$anonymous$$ouseOver etc. Its not particularly precise apparently, raycasting is the better way.
Answer by anthot4 · May 08, 2018 at 01:45 PM
The OnPointerDown event only works on ui elements. It doesn't work on gameobjects. To do the same with gameobjects its best to do it by raycasting.