// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System; using UltimateXR.Avatar.Rig; using UltimateXR.Core; using UnityEngine; namespace UltimateXR.Devices.Visualization { /// /// Describes the properties of a VR controller input element. /// [Serializable] public class UxrElement { #region Inspector Properties/Serialized Fields [SerializeField] private UxrElementType _elementType = UxrElementType.NotSet; [SerializeField] private UxrHandSide _hand; [SerializeField] private UxrControllerElements _element; [SerializeField] private GameObject _gameObject; [SerializeField] private UxrFingerType _finger; [SerializeField] private GameObject _fingerContactPoint; [SerializeField] private Vector3 _buttonPressedOffset; [SerializeField] private Vector3 _input1DPressedOffsetAngle; [SerializeField] private Vector3 _input1DPressedOffset; [SerializeField] private Vector3 _input2DFirstAxisOffsetAngle; [SerializeField] private Vector3 _input2DSecondAxisOffsetAngle; [SerializeField] private Vector3 _input2DFirstAxisOffset; [SerializeField] private Vector3 _input2DSecondAxisOffset; [SerializeField] private Vector3 _dpadFirstAxisOffsetAngle; [SerializeField] private Vector3 _dpadSecondAxisOffsetAngle; [SerializeField] private Vector3 _dpadFirstAxisOffset; [SerializeField] private Vector3 _dpadSecondAxisOffset; #endregion #region Public Types & Data /// /// Gets the input element type. /// public UxrElementType ElementType => _elementType; /// /// Gets which controller element(s) the input element describes. /// public UxrControllerElements Element => _element; /// /// Gets the object that represents the input element. /// public GameObject ElementObject => _gameObject; /// /// Gets which finger interacts with the input element. /// public UxrFingerType Finger => _finger; /// /// Gets the finger contact point if there is any. If null it will try to contact 's /// transform. /// public GameObject FingerContactPoint => _fingerContactPoint; /// /// Gets the pressed offset for a input element. /// public Vector3 ButtonPressedOffset => _buttonPressedOffset; /// /// Gets the pressed offset euler angles for a input element. /// public Vector3 Input1DPressedOffsetAngle => _input1DPressedOffsetAngle; /// /// Gets the pressed offset for a input element. /// public Vector3 Input1DPressedOffset => _input1DPressedOffset; /// /// Gets the maximum positive angle range for the first axis in a /// input element. The other side will be the negated angle. /// public Vector3 Input2DFirstAxisOffsetAngle => _input2DFirstAxisOffsetAngle; /// /// Gets the maximum positive angle range for the second axis in a /// input element. The other side will be the negated angle. /// public Vector3 Input2DSecondAxisOffsetAngle => _input2DSecondAxisOffsetAngle; /// /// Gets the maximum positive offset of the first axis in a input /// element. The other side will be the negated offset. /// public Vector3 Input2DFirstAxisOffset => _input2DFirstAxisOffset; /// /// Gets the maximum positive offset of the second axis in a input /// element. The other side will be the negated offset. /// public Vector3 Input2DSecondAxisOffset => _input2DSecondAxisOffset; /// /// Gets the maximum positive angle range for the first axis in a input element. The /// other side will be the negated angle. /// public Vector3 DpadFirstAxisOffsetAngle => _dpadFirstAxisOffsetAngle; /// /// Gets the maximum positive angle range for the second axis in a input element. /// The other side will be the negated angle. /// public Vector3 DpadSecondAxisOffsetAngle => _dpadSecondAxisOffsetAngle; /// /// Gets the maximum positive offset for the first axis in a input element. The /// other side will be the negated offset. /// public Vector3 DpadFirstAxisOffset => _dpadFirstAxisOffset; /// /// Gets the maximum positive offset for the second axis in a input element. The /// other side will be the negated offset. /// public Vector3 DpadSecondAxisOffset => _dpadSecondAxisOffset; /// /// Gets the hand that is used to interact with the input. /// public UxrHandSide HandSide { get => _hand; internal set => _hand = value; } #endregion #region Internal Types & Data /// /// Gets or sets the transform's initial local position. /// internal Vector3 InitialLocalPos { get; set; } /// /// Gets or sets the transform's initial local rotation. /// internal Quaternion InitialLocalRot { get; set; } /// /// Gets or sets the initial local position of the finger point of contact. /// internal Vector3 FingerContactInitialLocalPos { get; set; } /// /// Gets or sets the local right (X) offset axis. /// internal Vector3 LocalOffsetX { get; set; } /// /// Gets or sets the local up (Y) offset axis. /// internal Vector3 LocalOffsetY { get; set; } /// /// Gets or sets the local forward (Z) offset axis. /// internal Vector3 LocalOffsetZ { get; set; } /// /// Gets or sets the local right (X) offset of the finger point of contact. /// internal Vector3 LocalFingerPosOffsetX { get; set; } /// /// Gets or sets the local up (Y) offset of the finger point of contact. /// internal Vector3 LocalFingerPosOffsetY { get; set; } /// /// Gets or sets the local forward (Z) offset of the finger point of contact. /// internal Vector3 LocalFingerPosOffsetZ { get; set; } #endregion } }