【Unity】EventTrigger で押下処理

DEVELOP, Unity

var currentTrigger = nextTriggerObject.AddComponent<EventTrigger>();
currentTrigger.triggers = new List<EventTrigger.Entry>();
// Press イベント作成。
{
    EventTrigger.Entry pointerDown = new EventTrigger.Entry();
    pointerDown.eventID = EventTriggerType.PointerDown;
    pointerDown.callback.AddListener((x) =>
    {
       // 処理書く。
    });
    // 登録。
    currentTrigger.triggers.Add(pointerDown);
}

Posted by kazupon