14
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

unityでマウスイベントを取得する

Posted at

unityのマウスイベント一覧

C#

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {

    // マウスボタンが押された時にコールされる
    void OnMouseDown() {
        print("MouseDown!");
    }

    // マウスボタンを離した時にコールされる
    void OnMouseUp() {
        print("MouseUp!");
    }

    // マウスカーソルが対象オブジェクトから退出した時にコールされる
    void OnMouseExit() {
        print("MouseExit!");
    }

    // マウスカーソルが対象オブジェクトに進入した時にコールされる
    void OnMouseEnter() {
        print("MouseEnter!");
    }

    // マウスカーソルが対象オブジェクトに重なっている間コールされ続ける
    void OnMouseOver() {
        print("MouseOver!");
    }

    // マウスボタンが押された状態でマウスを移動させてる間コールされ続ける
    void OnMouseDrag() {
        print("MouseDrag!");
    }
14
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?