[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

https://everycommit.tistory.com/38

https://you-rang.tistory.com/407

반응형
: