// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using UltimateXR.Core; using UltimateXR.Core.Components; using UnityEngine; using UnityEngine.UI; namespace UltimateXR.Devices.DebugPanels { /// /// UI Widget for a single-axis input element in a VR input controller. Examples are trigger buttons, grip buttons... /// public class UxrDebugInput1dUI : UxrComponent { #region Inspector Properties/Serialized Fields [SerializeField] private UxrControllerInput _controllerInput; [SerializeField] private UxrHandSide _hand; [SerializeField] private UxrInput1D _target; [SerializeField] private Text _name; [SerializeField] private RectTransform _cursor; [SerializeField] private float _coordAmplitude; #endregion #region Public Types & Data /// /// Gets or sets the controller(s) to monitor for input. /// public UxrControllerInput TargetController { get => _controllerInput; set => _controllerInput = value; } /// /// Gets or sets the hand to monitor for input. /// public UxrHandSide TargetHand { get => _hand; set => _hand = value; } /// /// Gets or sets the single-axis element to monitor. /// public UxrInput1D Target { get => _target; set => _target = value; } #endregion #region Unity /// /// Updates the widget information. /// private void Update() { _name.text = $"{_hand} {_target}"; if (_controllerInput != null) { _cursor.anchoredPosition = new Vector2(0.0f, 1.0f) * (_coordAmplitude * _controllerInput.GetInput1D(_hand, _target, true)); } } #endregion } }