前提
InputSystemがインストールされている前提となります。
インストールがまだの方は以下の記事よりインストールしてからお進みください。
マウスのボタンの種類
ボタン | 説明 |
---|---|
leftButton | 左ボタン |
rightButton | 右ボタン |
rightButton | 右ボタン |
middleButton | 中央ボタン |
マウスイベントの種類
イベント | 説明 |
---|---|
isPressed | 押され続けている |
wasPressedThisFrame | 押された瞬間 |
wasReleasedThisFrame | 離された瞬間 |
マウス座標の取得
Vector2 position = mouse.position.ReadValue();
前フレームからのマウスポインター移動差分
Vector2 delta = mouse.delta.ReadValue();
nullチェックを入れたほうがいいみたい
var mouse = Mouse.current; if (mouse != null) { }