Image : MaskableGraphic: Graphic:ICanvasElement
Text : MaskableGraphic: Graphic:ICanvasElement
Button : Selectable
eventsystem 控制着 所有 baseinputmodule 和 所有 eventsystem
eventsystem通过baseinputmodule的数据 去生成 射线 判断是否可点击
baseinputmodule通过ExecuteEvents.Execute 触发 所有实现接口 的 类的返回
EventTrigger 实现 所有 点击接口 ,拖动接口,
如果我们需要点击接口。
可以添加eventtrigger脚本,或者自己实现接口
在eventtrigger 里面的triggers添加即可
public List<Entry> triggers
{
get
{
if (m_Delegates == null)
m_Delegates = new List<Entry>();
return m_Delegates;
}
set { m_Delegates = value; }
}
private void Execute(EventTriggerType id, BaseEventData eventData)
{
for (int i = 0, imax = triggers.Count; i < imax; ++i)
{
var ent = triggers[i];
if (ent.eventID == id && ent.callback != null)
ent.callback.Invoke(eventData);
}
}
public class Entry
{
// 摘要:
// The desired TriggerEvent to be Invoked.
public EventTrigger.TriggerEvent callback;
//
// 摘要:
// What type of event is the associated callback listening for.
public EventTriggerType eventID;
public Entry();
}
triggerevent 可以 addlistener
unityevent 可以 addlistener
TriggerEvent : UnityEvent<BaseEventData> : UnityEventBase
ButtonClickedEvent : UnityEvent : UnityEventBase
不需要实例化
public abstract class UnityEvent<T0> : UnityEventBase
{
[RequiredByNativeCode]
public UnityEvent();
public void AddListener(UnityAction<T0> call);
protected override MethodInfo FindMethod_Impl(string name, object targetObj);
public void Invoke(T0 arg0);
public void RemoveListener(UnityAction<T0> call);
}
addlistener可以add unityaction的委托
event.addlisten( unityaction )