Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Mouse2

Middle mouse button (or third button).
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Field
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
Mouse2 = 325

Remarks

Use this to detect middle mouse button presses. The “2” mouse button is the third button on the user’s mouse, which is usually the middle mouse button (often a clickable scroll wheel). Unity defines this as the "2" mouse button, as the mouse button numbering begins at 0.

Examples

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 "); } }}