123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using UnityEngine;
- using System.Collections;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- using System.Collections.Generic;
- namespace CurvedUI
- {
-
-
-
- public class CurvedUIPhysicsRaycaster : PhysicsRaycaster {
- #region VARIABLES AND SETTINGS
-
- [SerializeField]
- protected LayerMask eventMask = -1;
-
-
-
- RaycastHit hitInfo;
- RaycastResult result;
- #endregion
- #region CONSTRUCTOR
- protected CurvedUIPhysicsRaycaster() { }
- #endregion
- #region RAYCASTING
- public override void Raycast(PointerEventData eventData, List<RaycastResult> resultAppendList)
- {
-
- if (CurvedUIInputModule.Instance == null || CurvedUIInputModule.Instance.EventCamera == null)
- return;
- if (Physics.Raycast(CurvedUIInputModule.Instance.GetEventRay(), out hitInfo, float.PositiveInfinity, CompoundEventMask))
- {
- if (hitInfo.collider.GetComponentInParent<CurvedUISettings>()) return;
- result = new RaycastResult
- {
- gameObject = hitInfo.collider.gameObject,
- module = this,
- distance = hitInfo.distance,
- index = resultAppendList.Count,
- worldPosition = hitInfo.point,
- worldNormal = hitInfo.normal,
- };
- resultAppendList.Add(result);
- }
-
- }
- #endregion
- #region SETTERS AND GETTERS
-
-
-
- public int CompoundEventMask {
- get { return (eventCamera != null) ? eventCamera.cullingMask & eventMask : -1; }
- }
-
-
-
- public LayerMask EventMask {
- get { return eventMask; }
- set { eventMask = value; }
- }
-
-
-
- public override Camera eventCamera {
- get { return CurvedUIInputModule.Instance? CurvedUIInputModule.Instance.EventCamera : null; }
- }
- public virtual int Depth {
- get { return (eventCamera != null) ? (int)eventCamera.depth : 0xFFFFFF; }
- }
-
-
-
- #endregion
- }
- }
|