Mouse Click on Game Object – Unity3D (C#)


Mouse Click on Game Object – Unity3D (C#)

There are two ways to perform click function on a game object:

1- Create and attach a script to the target object. Write this function in it.

 

2- You can use Physics.Raycast to detect target with ray. You must write this code in script which is attached to camera. Be careful, this code works ONLY if the object in scene has collider.

 

 

©Coffee Break Codes – Mouse Click on Game Object – Unity3D (C#)


Leave a comment

Your email address will not be published. Required fields are marked *

4 thoughts on “Mouse Click on Game Object – Unity3D (C#)