mouse


This function is used for UI buttons mostly but sometimes we need it in game specs. It is implemented easily with mouse enter-exit listeners. We can change color of an object with renderers. Create a cube object and attach this script to it. At first, define 2 colors for standard […]

Change Color on Hover (Mouseover) – Unity3D (C#)


Camera Movement with Mouse – Unity3D (C#) This type of camera controller is mostly used in RTS projects. You can move camera with mouse movement. There are two types of camera movement with mouse: Touch the edges of screen or drag the mouse. In “Drag the Mouse” movement type, player […]

Camera Movement with Mouse – Unity3D (C#)


Drag Object with Mouse – Unity3D (C#) It’s too easy and quick to drag an object with mouse. Just use OnMouseDown() and OnMouseDrag() functions. [crayon-63dd615e1e95c315855474/] Save script and attach to object. That’s all!   ©Coffee Break Codes – Drag Object with Mouse – Unity3D (C#)

Drag Object with Mouse – Unity3D (C#)



Move Object to Mouse Click Position – Unity3D (C#) No matter 2D or 3D, we use same method to move an object to mouse click position. We need to get mouse click position on ground or whatever, and move object to this position. Create a plane and a cube. We […]

Move Object to Mouse Click Position – 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. [crayon-63dd615e439ed760873084/]   2- You can use Physics.Raycast to detect target with ray. You must write […]

Mouse Click on Game Object – Unity3D (C#)