From 8263edd59284aba390aca011d25b79efecef4c48 Mon Sep 17 00:00:00 2001 From: pryazha Date: Wed, 2 Jul 2025 08:46:23 -0700 Subject: init --- .../Scripts/ToggleGameObject.cs | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs (limited to 'Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs') diff --git a/Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs b/Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs new file mode 100644 index 0000000..ac7f7e3 --- /dev/null +++ b/Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs @@ -0,0 +1,47 @@ +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); + } + } +} -- cgit v1.2.3-70-g09d2