キーボード、マウスの処理を整理

キーボート
マウスの処理を見つけたのでメモ!

非常に簡単で以下の3つでした。

//キーボード判定など(以下は矢印と、「d」のボタン押す処理)
update() {
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) {
this.gameObject.transform.Translate(0.05f, 0.03f, 0);
}
}

// 左ボタンクリック
if (Input.GetMouseButtonUp(0))
{
Vector3 mousePosition = Input.mousePosition;
Debug.Log(“LeftClick:”+mousePosition );
}
// 右ボタンクリック
if (Input.GetMouseButtonUp(1))
{
Vector3 mousePosition = Input.mousePosition;
Debug.Log(“RightClick:”+mousePosition );
}
// 中ボタンクリック
if (Input.GetMouseButtonUp(2))
{
Vector3 mousePosition = Input.mousePosition;
Debug.Log(“MiddleClick:”+mousePosition );
}

ブログランキング


ゲーム開発ランキング
※↑最後にポチッとして頂ければ励みになります<(_ _)>

シェアする

  • このエントリーをはてなブックマークに追加

フォローする