// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using UltimateXR.Core.Components; using UnityEngine; namespace UltimateXR.Guides { /// /// /// When attached to a GameObject, it will tell the where to point to. Otherwise the /// compass will always point to the GameObject's transform. /// /// It can be used to highlight different spots depending on the . /// public class UxrCompassTargetHint : UxrComponent { #region Inspector Properties/Serialized Fields [SerializeField] private Transform _defaultTarget; [SerializeField] private Transform _locationTarget; [SerializeField] private Transform _grabTarget; [SerializeField] private Transform _lookTarget; [SerializeField] private Transform _useTarget; #endregion #region Public Types & Data /// /// Gets or sets the target where the should point to by default, if the other transforms are /// null or not applicable. /// public Transform DefaultTarget { get => _defaultTarget; set => _defaultTarget = value; } /// /// Gets or sets the target where the should point to when /// is . /// public Transform LocationTarget { get => _locationTarget; set => _locationTarget = value; } /// /// Gets or sets the target where the should point to when /// is . /// public Transform GrabTarget { get => _grabTarget; set => _grabTarget = value; } /// /// Gets or sets the target where the should point to when /// is . /// public Transform LookTarget { get => _lookTarget; set => _lookTarget = value; } /// /// Gets or sets the target where the should point to when /// is . /// public Transform UseTarget { get => _useTarget; set => _useTarget = value; } #endregion #region Public Methods /// /// Gets the appropriate transform where the compass should point to. /// /// Display mode to get the transform for /// Transform where the compass should point to public Transform GetTransform(UxrCompass compass) { switch (compass.DisplayMode) { case UxrCompassDisplayMode.Location: return LocationTarget != null ? LocationTarget : DefaultTarget != null ? DefaultTarget : transform; case UxrCompassDisplayMode.Grab: return GrabTarget != null ? GrabTarget : DefaultTarget != null ? DefaultTarget : transform; case UxrCompassDisplayMode.Look: return LookTarget != null ? LookTarget : DefaultTarget != null ? DefaultTarget : transform; case UxrCompassDisplayMode.Use: return UseTarget != null ? LookTarget : DefaultTarget != null ? DefaultTarget : transform; } return DefaultTarget != null ? DefaultTarget : transform; } #endregion } }