Version: 2017.3

Input.GetMouseButton

切换到手册
public static bool GetMouseButton (int button);

描述

返回是否按下了给定的鼠标按钮。

button values are 0 for left button, 1 for right button, 2 for the middle button.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetMouseButton(0)) Debug.Log("Pressed left click."); if (Input.GetMouseButton(1)) Debug.Log("Pressed right click."); if (Input.GetMouseButton(2)) Debug.Log("Pressed middle click."); } }