summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-04-02 19:07:01 +0800
committerchai <chaifix@163.com>2021-04-02 19:07:01 +0800
commit6b25723ca33a657882588b2cc3a58101bb9d33e6 (patch)
treefa79c1e553f58586e4c659d0e71933f9f6ae3894
parentb1276a1b76ac3b87add90e0c6b887d5afea1cfea (diff)
+misc
-rw-r--r--Assets/Scripts/CapsuleButton.cs6
-rw-r--r--Assets/Scripts/PicoButton.cs6
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs2
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs4
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs1
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs8
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs13
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs28
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs1
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs1
10 files changed, 45 insertions, 25 deletions
diff --git a/Assets/Scripts/CapsuleButton.cs b/Assets/Scripts/CapsuleButton.cs
index 9adee0f..8d19868 100644
--- a/Assets/Scripts/CapsuleButton.cs
+++ b/Assets/Scripts/CapsuleButton.cs
@@ -8,17 +8,17 @@ public class CapsuleButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandl
{
public virtual void OnPointerClick(PointerEventData eventData)
{
- Debug.Log("CapsuleButton.OnPointerClick");
+ // Debug.Log("CapsuleButton.OnPointerClick");
}
public virtual void OnPointerUp(PointerEventData eventData)
{
- Debug.Log("CapsuleButton.OnPointerUp");
+ // Debug.Log("CapsuleButton.OnPointerUp");
}
public virtual void OnPointerDown(PointerEventData eventData)
{
- Debug.Log("CapsuleButton.OnPointerDown");
+ // Debug.Log("CapsuleButton.OnPointerDown");
}
}
diff --git a/Assets/Scripts/PicoButton.cs b/Assets/Scripts/PicoButton.cs
index 385f90f..e86f2c0 100644
--- a/Assets/Scripts/PicoButton.cs
+++ b/Assets/Scripts/PicoButton.cs
@@ -8,17 +8,17 @@ public class PicoButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler,
{
public virtual void OnPointerClick(PointerEventData eventData)
{
- Debug.Log("PicoButton.OnPointerClick");
+ // Debug.Log("PicoButton.OnPointerClick");
}
public virtual void OnPointerUp(PointerEventData eventData)
{
- Debug.Log("PicoButton.OnPointerUp");
+// Debug.Log("PicoButton.OnPointerUp");
}
public virtual void OnPointerDown(PointerEventData eventData)
{
- Debug.Log("PicoButton.OnPointerDown");
+// Debug.Log("PicoButton.OnPointerDown");
}
}
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs
index 7b5a60d..ecc94aa 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventData/BaseEventData.cs
@@ -2,7 +2,7 @@ namespace UnityEngine.EventSystems
{
public abstract class AbstractEventData
{
- protected bool m_Used; // 当前事件是否被吞(被处理)
+ protected bool m_Used; // 当前事件是否被处理(被吞)
public virtual void Reset()
{
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs
index 3456e7b..801daae 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/EventSystem.cs
@@ -183,6 +183,7 @@ namespace UnityEngine.EventSystems
public void RaycastAll(PointerEventData eventData, List<RaycastResult> raycastResults)
{
raycastResults.Clear();
+ //包括场景中所有的raycaster
var modules = RaycasterManager.GetRaycasters();
for (int i = 0; i < modules.Count; ++i)
{
@@ -259,6 +260,7 @@ namespace UnityEngine.EventSystems
if (current != this)
return;
+ // 只更新鼠标位置
TickModules();
// 将m_CurrentInputModule设置为m_SystemInputModules第一个可用的module
@@ -291,7 +293,7 @@ namespace UnityEngine.EventSystems
}
}
- //c 执行事件处理主入口,通常情况下,如果没有自定义的inputModule,就是走StandaloneInputModule的Process
+ //c! 执行事件处理主入口,通常情况下,如果没有自定义的inputModule,就是走StandaloneInputModule的Process
if (!changedModule && m_CurrentInputModule != null)
m_CurrentInputModule.Process();
}
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
index 71fd9f3..a749ce8 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/ExecuteEvents.cs
@@ -4,6 +4,7 @@ using UnityEngine.UI;
namespace UnityEngine.EventSystems
{
+ // 最关键的类,调用gameobject对应的回调函数
public static class ExecuteEvents
{
public delegate void EventFunction<T1>(T1 handler, BaseEventData eventData);
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs
index 7661a8e..66736d1 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs
@@ -15,10 +15,10 @@ namespace UnityEngine.EventSystems
private BaseEventData m_BaseEventData;
#region 输入系统
- // 如果m_InputOverride不为空就用它,否则用默认的m_DefaultInput
- // 如果要自己实现BaseInput,继承此类并给这个字段赋值
- // StandaloneInputModule没有自定义,直接采用的是BaseInput
- protected BaseInput m_InputOverride;
+ // 如果m_InputOverride不为空就用它,否则用默认的m_DefaultInput
+ // 如果要自己实现BaseInput,继承此类并给这个字段赋值
+ // StandaloneInputModule没有自定义,直接采用的是BaseInput
+ protected BaseInput m_InputOverride;
private BaseInput m_DefaultInput;
public BaseInput input
{
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs
index 9103162..3f93e7a 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs
@@ -4,6 +4,8 @@ using UnityEngine.UI;
namespace UnityEngine.EventSystems
{
+
+ // 会处理触屏和鼠标
public abstract class PointerInputModule : BaseInputModule
{
public const int kMouseLeftId = -1;
@@ -37,7 +39,8 @@ namespace UnityEngine.EventSystems
protected PointerEventData GetTouchPointerEventData(Touch input, out bool pressed, out bool released)
{
PointerEventData pointerData;
- var created = GetPointerData(input.fingerId, out pointerData, true); // 拿到存储结构,返回是否是新建结构
+ // 从池子里拿到存储结构,返回是否是新建结构
+ var created = GetPointerData(input.fingerId, out pointerData, true);
pointerData.Reset();
@@ -60,8 +63,10 @@ namespace UnityEngine.EventSystems
// 用这个触摸数据做射线检测,检测结果在m_RaycastResultCache
eventSystem.RaycastAll(pointerData, m_RaycastResultCache);
-
+
+ // 只取第一个,舍弃其他的
var raycast = FindFirstRaycast(m_RaycastResultCache);
+ Debug.Log("raycast: " + raycast.index);
pointerData.pointerCurrentRaycast = raycast;
m_RaycastResultCache.Clear();
return pointerData;
@@ -209,6 +214,8 @@ namespace UnityEngine.EventSystems
leftData.scrollDelta = input.mouseScrollDelta;
leftData.button = PointerEventData.InputButton.Left;
eventSystem.RaycastAll(leftData, m_RaycastResultCache);
+
+ // 只要第一个raycast结果
var raycast = FindFirstRaycast(m_RaycastResultCache);
leftData.pointerCurrentRaycast = raycast;
m_RaycastResultCache.Clear();
@@ -224,6 +231,7 @@ namespace UnityEngine.EventSystems
CopyFromTo(leftData, middleData);
middleData.button = PointerEventData.InputButton.Middle;
+ // 设置按键状态
m_MouseState.SetButtonState(PointerEventData.InputButton.Left, StateForMouseButton(0), leftData);
m_MouseState.SetButtonState(PointerEventData.InputButton.Right, StateForMouseButton(1), rightData);
m_MouseState.SetButtonState(PointerEventData.InputButton.Middle, StateForMouseButton(2), middleData);
@@ -252,6 +260,7 @@ namespace UnityEngine.EventSystems
HandlePointerExitAndEnter(pointerEvent, targetGO);
}
+ // 发送drag事件
protected virtual void ProcessDrag(PointerEventData pointerEvent)
{
if (!pointerEvent.IsPointerMoving() ||
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs
index f9a2f77..7db371a 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs
@@ -141,16 +141,16 @@ namespace UnityEngine.EventSystems
default:
return false;
}
- }
-
- //c 更新鼠标坐标
+ }
+
+ //c! 这里只更新鼠标位置
public override void UpdateModule()
{
- // 如果没有获取焦点,且忽略没有焦点时的事件,返回(除非开启远程连接,否则会这样)
+ // 如果没有获取焦点,且忽略没有焦点时的事件,返回(除非开启远程连接,否则会这样)
if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus())
return;
- // 更新鼠标位置
+ // 更新鼠标位置
m_LastMousePosition = m_MousePosition;
m_MousePosition = input.mousePosition;
}
@@ -201,16 +201,17 @@ namespace UnityEngine.EventSystems
ClearSelection();
}
- //c input module事件处理主入口
+ //c! input module事件处理主入口,每帧更新
public override void Process()
{
- if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) // 如果没有获取焦点,不需要处理
+ // 如果没有获取焦点,不需要处理
+ if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus())
return;
//event 给选中的对象发布更新事件
bool usedEvent = SendUpdateEventToSelectedObject();
- // 如果勾上了,发送move , submit, cancel事件
+ // 如果勾上了Send Navigation Events,发送move , submit, cancel事件
if (eventSystem.sendNavigationEvents)
{
if (!usedEvent)
@@ -222,10 +223,10 @@ namespace UnityEngine.EventSystems
// 模拟触摸或鼠标输入
// touch needs to take precedence because of the mouse emulation layer
- usedEvent = ProcessTouchEvents(); //event 发布触摸事件
+ usedEvent = ProcessTouchEvents(); //event 检测屏幕触摸,PC上没有
if(!usedEvent && input.mousePresent)
- ProcessMouseEvent();
+ ProcessMouseEvent(); // 处理鼠标事件
}
//c 触摸事件
@@ -233,6 +234,8 @@ namespace UnityEngine.EventSystems
{
for (int i = 0; i < input.touchCount; ++i) //多点触控
{
+ Debug.Log("Touch");
+
Touch touch = input.GetTouch(i);
if (touch.type == TouchType.Indirect)
@@ -240,7 +243,8 @@ namespace UnityEngine.EventSystems
bool released; // 这是一个手指抬起操作
bool pressed; // 这是一个手指放下操作
- var pointer = GetTouchPointerEventData(touch, out pressed, out released); // 射线检测并保存检测结果
+ //
+ PointerEventData pointer = GetTouchPointerEventData(touch, out pressed, out released); // 射线检测并保存检测结果
// 处理触摸或抬起反馈,已经准备好了被触摸的物体
ProcessTouchPress(pointer, pressed, released);
@@ -495,6 +499,7 @@ namespace UnityEngine.EventSystems
}
}
+ // 每帧发送一个OnUpdateSelected事件
protected bool SendUpdateEventToSelectedObject()
{
if (eventSystem.currentSelectedGameObject == null)
@@ -506,6 +511,7 @@ namespace UnityEngine.EventSystems
return data.used;
}
+ // 处理鼠标按下事件,发送消息,调用回调
/// <summary>
/// Process the current mouse press.
/// </summary>
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs
index f9a8558..d58c358 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/BaseRaycaster.cs
@@ -32,6 +32,7 @@ namespace UnityEngine.EventSystems
"renderOrderPriority: " + renderOrderPriority;
}
+ // 只要是继承了BaseRaycaster的都会自动加到raycaster的列表里面
protected override void OnEnable()
{
base.OnEnable();
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs
index bc65cbb..2582204 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/GraphicRaycaster.cs
@@ -79,6 +79,7 @@ namespace UnityEngine.UI
if (canvas == null)
return;
+ // 拿到canvas下的所有graphic
var canvasGraphics = GraphicRegistry.GetGraphicsForCanvas(canvas);
if (canvasGraphics == null || canvasGraphics.Count == 0)
return;