描述

中间鼠标按钮(或第三按钮)。

这可用于检测中间鼠标按钮的按下。“2”鼠标按钮是用户鼠标上的第三按钮,通常是中间鼠标按钮(通常是可单击的滚轮)。Unity 将此定义为“2”鼠标按钮,因为鼠标按钮编号从 0 开始。

using UnityEngine;

public class Example : MonoBehaviour { void Update() { //Detect if the middle mouse button is pressed if (Input.GetKey(KeyCode.Mouse2)) { Debug.Log("Mouse 2 "); } } }