namespace UnityEngine.XR.Interaction.Toolkit.Samples.Hands
{
///
/// Toggles the active state of a GameObject.
///
public class ToggleGameObject : MonoBehaviour
{
[SerializeField]
[Tooltip("The GameObject to toggle the active state for.")]
GameObject m_ActivationGameObject;
///
/// The GameObject to toggle the active state for.
///
public GameObject activationGameObject
{
get => m_ActivationGameObject;
set => m_ActivationGameObject = value;
}
[SerializeField]
[Tooltip("Whether the GameObject is currently active.")]
bool m_CurrentlyActive;
///
/// Whether the GameObject is currently active.
///
public bool currentlyActive
{
get => m_CurrentlyActive;
set
{
m_CurrentlyActive = value;
activationGameObject.SetActive(m_CurrentlyActive);
}
}
///
/// Toggles the active state of the GameObject.
///
public void ToggleActiveState()
{
m_CurrentlyActive = !m_CurrentlyActive;
activationGameObject.SetActive(m_CurrentlyActive);
}
}
}