From b1276a1b76ac3b87add90e0c6b887d5afea1cfea Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 11 Oct 2020 09:12:08 +0800 Subject: =?UTF-8?q?*event=20system=E5=88=9D=E6=8E=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs | 1 + .../UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs index 783cf95..6346938 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs @@ -13,6 +13,7 @@ namespace UnityEngine.EventSystems protected Physics2DRaycaster() {} + // 发射线 public override void Raycast(PointerEventData eventData, List resultAppendList) { if (eventCamera == null) diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs index 2b4bea3..c7d431c 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs @@ -3,6 +3,8 @@ using UnityEngine.UI; namespace UnityEngine.EventSystems { + //c 投射3D物体的相机挂这个脚本 + /// /// Simple event system using physics raycasts. /// @@ -66,7 +68,7 @@ namespace UnityEngine.EventSystems { ray = eventCamera.ScreenPointToRay(eventData.position); // compensate far plane distance - see MouseEvents.cs - float projectionDirection = ray.direction.z; + float projectionDirection = ray.direction.z; // ray.direction是归一化了的 distanceToClipPlane = Mathf.Approximately(0.0f, projectionDirection) ? Mathf.Infinity : Mathf.Abs((eventCamera.farClipPlane - eventCamera.nearClipPlane) / projectionDirection); @@ -78,6 +80,7 @@ namespace UnityEngine.EventSystems if (eventCamera == null || !eventCamera.pixelRect.Contains(eventData.position)) return; + // 根据触摸数据拿到射线 Ray ray; float distanceToClipPlane; ComputeRayAndDistance(eventData, out ray, out distanceToClipPlane); -- cgit v1.1-26-g67d0