using System;
using UnityEngine.XR.Interaction.Toolkit.Inputs.Readers;
using UnityEngine.XR.Interaction.Toolkit.Inputs.Simulation.Hands;
namespace UnityEngine.XR.Interaction.Toolkit.Inputs.Simulation
{
///
/// A hand expression that can be simulated by performing an input action.
///
[Serializable]
public class SimulatedHandExpression : ISerializationCallbackReceiver
{
[SerializeField]
[Tooltip("The unique name for the hand expression.")]
[Delayed]
string m_Name;
///
/// The name of the hand expression to simulate when the input action is performed.
///
public string name => m_ExpressionName.ToString();
[SerializeField]
[Tooltip("The input to trigger the simulated hand expression.")]
XRInputButtonReader m_ToggleInput;
///
/// The input to trigger the simulated hand expression.
///
public XRInputButtonReader toggleInput
{
get => m_ToggleInput;
set => m_ToggleInput = value;
}
[SerializeField]
[Tooltip("The captured hand expression to simulate when the input action is performed.")]
HandExpressionCapture m_Capture;
///
/// The captured expression to simulate when the input action is performed.
///
internal HandExpressionCapture capture
{
get => m_Capture;
set => m_Capture = value;
}
[SerializeField]
[Tooltip("Whether or not this expression appears in the quick action list in the simulator.")]
bool m_IsQuickAction;
///
/// Whether or not this expression appears in the quick action list in the simulator.
///
public bool isQuickAction
{
get => m_IsQuickAction;
set => m_IsQuickAction = value;
}
HandExpressionName m_ExpressionName;
///
/// The name of the hand expression to simulate when the input action is performed.
/// Use this for a faster name identifier than comparing by name.
///
internal HandExpressionName expressionName
{
get => m_ExpressionName;
set => m_ExpressionName = value;
}
///
/// Sprite icon for the simulated hand expression.
///
public Sprite icon => m_Capture.icon;
///
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
m_Name = m_ExpressionName.ToString();
}
///
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
m_ExpressionName = new HandExpressionName(m_Name);
}
}
}