using System.Collections.Generic;
using TMPro;
namespace UnityEngine.XR.Hands.Samples.Gestures.DebugTools
{
///
/// Controls the debug UI for bar states by scaling bars.
///
public class XRFingerShapeDebugUI : MonoBehaviour
{
[SerializeField]
[Tooltip("The list of 5 bars to display the finger state values.")]
List m_Bars = new List();
[SerializeField]
[Tooltip("The label that will be used to display the name of the finger.")]
TextMeshProUGUI m_FingerNameLabel;
///
/// The list of 5 bars to display the finger state values
///
public List bars
{
get => m_Bars;
set => m_Bars = value;
}
///
/// Set the value of a particular bar.
///
/// The bar that has the given state value.
/// The value for the given bar.
public void SetFingerShape(int barIndex, float value)
{
value = Mathf.Clamp(value, 0f, 1f);
m_Bars[barIndex].SetValue(value);
}
///
/// Hides the bar for the given bar.
///
/// The bar that should have its bar hidden.
public void HideFingerShape(int barIndex) => m_Bars[barIndex].HideValue();
///
/// Set the name of the finger for this finger state debug UI.
///
/// The string to put on the label.
public void SetFingerName(string fingerName)
{
if (m_FingerNameLabel != null)
m_FingerNameLabel.text = fingerName;
}
}
}