// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using UltimateXR.Core; using UnityEngine.EventSystems; using UnityEngine.UI; namespace UltimateXR.UI.UnityInputModule { /// /// Base Unity UI Graphic raycaster class. /// public abstract class UxrGraphicRaycaster : GraphicRaycaster { #region Public Methods /// /// Checks whether the raycast result describes a collision against a 2D or 3D object. /// /// Raycast result /// Whether collision is against a 2D or 3D object public static bool Is2DOr3DRaycastResult(RaycastResult result) { return result.depth == UxrConstants.UI.Depth2DObject || result.depth == UxrConstants.UI.Depth3DObject; } /// /// Compares two raycast results. /// /// Raycast result 1 /// Raycast result 2 /// Less than 0 if a is closer than b, 0 if they are at the same distance and greater than 0 if b is closer than a public static int CompareDepth(RaycastResult a, RaycastResult b) { if (Is2DOr3DRaycastResult(a) || Is2DOr3DRaycastResult(b)) { return a.distance.CompareTo(b.distance); } return a.depth.CompareTo(b.depth); } #endregion } }