[GVR] unity reticle pointer + event trigger (point down, up)
Unity3D 2021. 7. 30. 12:15
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Cube2 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
EventTrigger trigger = GetComponent<EventTrigger>();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerDown;
entry.callback.AddListener((data) => { OnPointerDownDelegate((PointerEventData)data); });
trigger.triggers.Add(entry);
EventTrigger.Entry entry2 = new EventTrigger.Entry();
entry2.eventID = EventTriggerType.PointerUp;
entry2.callback.AddListener((data) => { OnPointerUpDelegate((PointerEventData)data); });
trigger.triggers.Add(entry2);
}
public void OnPointerDownDelegate(PointerEventData data)
{
Debug.Log("OnPointerDownDelegate called.");
}
public void OnPointerUpDelegate(PointerEventData data)
{
Debug.Log("OnPointerUpDelegate called.");
}
}
https://docs.unity3d.com/kr/530/ScriptReference/EventSystems.EventTrigger.html
https://docs.unity3d.com/kr/530/ScriptReference/Events.UnityEvent.html
https://m.blog.naver.com/ekbae98/221254703234
https://onepinetwopine.tistory.com/243
'Unity3D' 카테고리의 다른 글
[GVR] 시선으로 이동, 래티클 사용해서 바라보면 멈추기 (0) | 2021.07.30 |
---|---|
유랑님 블로그 (유니티 튜토리얼) (0) | 2021.07.30 |
Unity GoogleVR (0) | 2021.07.29 |
A failure occurred while executing com.android.build.gradle.internal.tasks (0) | 2021.07.20 |
logcat monitor (0) | 2021.02.03 |