unity getmousebuttondown code example

Example 1: unity left mouse button

//Key Code in the Input Project Settings is "mouse 0"
Input.GetKey(KeyCode.Mouse0))

Example 2: left moust click unity

//Left mouse Click
if(Input.GetMouseButtonDown(0))

//Right Mouse Click
if(Input.GetMouseButtonDown(1))

//Scroll Wheel
if(Input.GetMouseButtonDown(2))

Example 3: GetMousebuttonDown unity

if (Input.GetMouseButtonDown(1))
//This is too stop spaming the gun

Example 4: Input.getMouseButton

if (Input.GetMouseButton(2))
        {
            Debug.Log("Pressed middle click.");
        }

Tags:

Misc Example