using System.Collections.Generic; using UnityEngine.UI; namespace UnityEngine.EventSystems { /// /// Simple event system using physics raycasts. /// [AddComponentMenu("Event/Physics 2D Raycaster")] [RequireComponent(typeof(Camera))] public class Physics2DRaycaster : PhysicsRaycaster { protected Physics2DRaycaster() {} // ·ΆΙδΟί public override void Raycast(PointerEventData eventData, List resultAppendList) { if (eventCamera == null) return; Ray ray; float distanceToClipPlane; ComputeRayAndDistance(eventData, out ray, out distanceToClipPlane); if (ReflectionMethodsCache.Singleton.getRayIntersectionAll == null) return; var hits = ReflectionMethodsCache.Singleton.getRayIntersectionAll(ray, distanceToClipPlane, finalEventMask); if (hits.Length != 0) { for (int b = 0, bmax = hits.Length; b < bmax; ++b) { var sr = hits[b].collider.gameObject.GetComponent(); var result = new RaycastResult { gameObject = hits[b].collider.gameObject, module = this, distance = Vector3.Distance(eventCamera.transform.position, hits[b].point), worldPosition = hits[b].point, worldNormal = hits[b].normal, screenPosition = eventData.position, index = resultAppendList.Count, sortingLayer = sr != null ? sr.sortingLayerID : 0, sortingOrder = sr != null ? sr.sortingOrder : 0 }; resultAppendList.Add(result); } } } } }