Input.GetMouseButton
Declaration
public static bool GetMouseButton(int button);Описание
Возвращает информацию о том, удерживается ли указанная кнопка мыши.
Примечание: Этот API является частью устаревшего менеджера ввода. Рекомендуется не использовать этот API в новых проектах. Для новых проектов используйте пакет Input System. Чтобы узнать больше о вводе, смотрите Ввод.
Значения кнопки: 0 для левой кнопки, 1 для правой кнопки, 2 для средней кнопки. Возвращается true при нажатии кнопки мыши и false при ее освобождении.
using UnityEngine; using System.Collections;
// Detects clicks from the mouse and prints a message // depending on the click detected.
public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetMouseButton(0)) { Debug.Log("The left mouse button is being held down."); }
if (Input.GetMouseButton(1)) { Debug.Log("The right mouse button is being held down."); }
if (Input.GetMouseButton(2)) { Debug.Log("The middle mouse button is being held down."); } } }