48 lines
1.3 KiB
C#
Raw Normal View History

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