// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using UltimateXR.Avatar; using UltimateXR.Core; using UnityEngine; using UnityEngine.EventSystems; namespace UltimateXR.UI.UnityInputModule { /// /// Event data class that adds information required by to facilitate the /// processing of UI interaction events. /// public class UxrPointerEventData : PointerEventData { #region Public Types & Data /// /// Gets whether the event data contains valid information. /// public bool HasData => pointerCurrentRaycast.isValid || IgnoredGameObject != null || IsNonUI; /// /// Gets the responsible for the interaction. /// public UxrAvatar Avatar { get; } /// /// Gets the hand responsible for the interaction. /// public UxrHandSide HandSide { get; } /// /// Gets the finger tip if this event is being processed by one. Null if not. /// public UxrFingerTip FingerTip { get; } /// /// Gets the laser pointer if this event is being processed by one. Null if not. /// public UxrLaserPointer LaserPointer { get; } /// /// Gets the current pointer world position. /// public Vector3 WorldPos { get; internal set; } /// /// Gets the pointer world position during the last frame. /// public Vector3 PreviousWorldPos { get; internal set; } /// /// Gets whether the world position has been initialized. /// public bool WorldPosInitialized { get; internal set; } /// /// Gets whether the pointer is pressing this frame. /// public bool PressedThisFrame { get; internal set; } /// /// Gets whether the pointer is pressing this frame. /// public bool ReleasedThisFrame { get; internal set; } /// /// Gets whether the current raycast UI element is interactive. /// public bool IsInteractive { get; internal set; } /// /// Gets whether the current raycast UI element is not a UI GameObject. /// This happens when the raycast is valid and the object has either a 2D or 3D collider. /// public bool IsNonUI => GameObject2D != null || GameObject3D != null; /// /// Gets the UI gameObject that was ignored because it could not be interacted with. /// public GameObject IgnoredGameObject { get; internal set; } /// /// Gets the gameObject if the raycast element is an object with a 3D collider. /// public GameObject GameObject3D { get; internal set; } /// /// Gets the gameObject if the raycast element is an object with a 2D collider. /// public GameObject GameObject2D { get; internal set; } /// /// Gets the that was clicked, if there was one. /// public GameObject GameObjectClicked { get; internal set; } /// /// Gets the current cursor speed. /// public float Speed { get; internal set; } #endregion #region Constructors & Finalizer /// /// Constructor. /// /// Event system /// Finger tip responsible for the event public UxrPointerEventData(EventSystem eventSystem, UxrFingerTip fingerTip) : base(eventSystem) { Avatar = fingerTip.Avatar; HandSide = fingerTip.Side; FingerTip = fingerTip; } /// /// Constructor. /// /// Event system /// Laser pointer responsible for the event public UxrPointerEventData(EventSystem eventSystem, UxrLaserPointer laserPointer) : base(eventSystem) { Avatar = laserPointer.Avatar; HandSide = laserPointer.HandSide; LaserPointer = laserPointer; } #endregion } }