Unity 更改EventTrigger插件里面的默认功能

 EventTrigger trigger = mySlider.gameObject.GetComponent<EventTrigger>();
        EventTrigger.Entry entry = new EventTrigger.Entry();
        // 鼠标点击事件
        entry.eventID = EventTriggerType.EndDrag;
        entry.callback = new EventTrigger.TriggerEvent();
        entry.callback.AddListener(OnClick);
        trigger.triggers.Add(entry);

    }

    private void OnClick(BaseEventData pointData) {
        Debug.Log("Button Clicked. EventTrigger..");
        string name = playBtn.GetComponent<Image>().sprite.name;
        if (name == playName) {
            vid.Play();
        } else {
            vid.Pause();
        }
    }

 

posted on 2022-01-13 10:39  zqiang0803  阅读(55)  评论(0编辑  收藏  举报

导航