using UnityEngine;
using System.Collections;
using UnityEngine.UI;
//一定要加載這個
using UnityEngine.EventSystems;
using UnityEngine.Events;
[RequireComponent(typeof(UnityEngine.EventSystems.EventTrigger))]
public class text12344 : MonoBehaviour {
void Awake(){
EventTrigger _trigger = this.GetComponent<EventTrigger>();
EventTrigger.Entry _entry = new EventTrigger.Entry();
// 要監聽事件的型態 直接重EventTriggerType. 去選擇
_entry.eventID = EventTriggerType.PointerDown;
_entry.callback = new EventTrigger.TriggerEvent();
UnityAction<BaseEventData> call = new UnityAction<BaseEventData>(OnDown);
_entry.callback.AddListener(call);
_trigger.triggers.Add(_entry);
}
// 一定要加參數 參數型態BaseEventData
public void OnDown(BaseEventData p ){
print ("DoSomeThing");
}
}
留言列表