How can I get the collider of the object’s transform the mouse is over by using OnMouseOver function
3 ways:
-
If you have your own script on the game object also having a collider, you just add an OnMouseOver function to that script. It will be called when mouse is over the collider and you get the collider with GetComponent on the game object.
-
Or you can create a specific script that just does above.
-
You can instead ray cast every frame and find the component that the ray hits (see here).