Help us understand the problem. What is going on with this article?

EventSystem を使った Tap入力処理

More than 5 years have passed since last update.
  1. Main Camera に Physics Raycasterコンポーネントを追加
  2. 「UI」→「EventSystem」を追加
  3. Tapしたときに入力を検出したい場所に Cube を配置する(形状に合わせて Cube以外のオブジェクトでもいい)
  4. Cube の Box Collider の Is Trigger のチェックをつける
  5. Cube の Mesh Renderer のチェックを外す( Cube が非表示になる)
  6. Cube に Add Component で Script を設定する
  7. IPointerDownHandler などのインターフェイスを追加する
いろいろ試してみる
using UnityEngine;
using UnityEngine.EventSystems;

public class PlayerMoveArea : MonoBehaviour
, IDeselectHandler
, IDragHandler
, IDropHandler
, IMoveHandler
, IPointerClickHandler
, IPointerDownHandler
, IPointerEnterHandler
, IPointerExitHandler
, IPointerUpHandler
, IScrollHandler
, ISelectHandler
, IUpdateSelectedHandler
{
    public void OnPointerEnter(PointerEventData eventData) { Debug.Log ("OnPointerEnter"); }
    public void OnPointerDown(PointerEventData eventData) { Debug.Log ("OnPointerDown"); }
    public void OnDrag(PointerEventData eventData) { Debug.Log ("OnDrag"); }
    public void OnPointerUp(PointerEventData eventData) { Debug.Log ("OnPointerUp"); }
    public void OnPointerExit(PointerEventData eventData) { Debug.Log ("OnPointerExit"); }

    public void OnPointerClick(PointerEventData eventData) { Debug.Log ("OnPointerClick"); }
    public void OnScroll(PointerEventData eventData) { Debug.Log ("OnScroll"); }

    public void OnDeselect(BaseEventData eventData) { Debug.Log ("OnDeselect"); }
    public void OnDrop(PointerEventData eventData) { Debug.Log ("OnDrop"); }
    public void OnMove(AxisEventData eventData) { Debug.Log ("OnMove"); }
    public void OnSelect(BaseEventData eventData) { Debug.Log ("OnSelect"); }
    public void OnUpdateSelected(BaseEventData eventData) { Debug.Log ("OnUpdateSelected"); }
}
hkomo746
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした