Calling OnMouseOver from a script on multiple colliders?


is it possible to call multiple OnMouseOver functions from a script referring to different colliders?

So it would basically be something like this:

“OnMouseOverCollider1 - do this”

“OnMouseOverCollider2 - do that”

Or is something like that only possible with a Raycast?

Thanks in advance :slight_smile:

i think you have to get each collider by raycast.

void OnMouseOver() {

RaycastHit hit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
              if(Physics.Raycast(ray, out hit))
                 if ( = "your name_1");
                 //do your code
                 if ( = "your name_2");
                 //do your code