Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@hkomo746

EventSystem を使った Tap入力処理

  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"); }
}
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
7
Help us understand the problem. What are the problem?