summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-11 09:12:08 +0800
committerchai <chaifix@163.com>2020-10-11 09:12:08 +0800
commitb1276a1b76ac3b87add90e0c6b887d5afea1cfea (patch)
treeae12e1bc24f6907c9870bf062d020d6ce1db6fa1 /Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
parent8d89ca7b0662cff2a93b33ed92205ff3f6170436 (diff)
*event system鍒濇帰
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs')
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
index bf77717..71fd9f3 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
@@ -233,8 +233,10 @@ namespace UnityEngine.EventSystems
}
}
+ //IEventSystemHandler是所有接口的基类
private static readonly ObjectPool<List<IEventSystemHandler>> s_HandlerListPool = new ObjectPool<List<IEventSystemHandler>>(null, l => l.Clear());
+ // 向target gameobject发送一个事件,对每个实现了T接口的类执行functor方法(就是接口中定义的回调)
public static bool Execute<T>(GameObject target, BaseEventData eventData, EventFunction<T> functor) where T : IEventSystemHandler
{
var internalHandlers = s_HandlerListPool.Get();
@@ -242,6 +244,8 @@ namespace UnityEngine.EventSystems
// if (s_InternalHandlers.Count > 0)
// Debug.Log("Executinng " + typeof (T) + " on " + target);
+ // 拿到实现了T接口的组件,调用对应的方法
+
for (var i = 0; i < internalHandlers.Count; i++)
{
T arg;
@@ -289,6 +293,7 @@ namespace UnityEngine.EventSystems
return null;
}
+ //c component是否匹配类型T且是否被激活
private static bool ShouldSendToComponent<T>(Component component) where T : IEventSystemHandler
{
var valid = component is T;
@@ -315,8 +320,10 @@ namespace UnityEngine.EventSystems
var components = ListPool<Component>.Get();
go.GetComponents(components);
+ // 遍历所有的组件,找到匹配类型T的
for (var i = 0; i < components.Count; i++)
{
+ // 如果不匹配类型T,跳过这个
if (!ShouldSendToComponent<T>(components[i]))
continue;