summaryrefslogtreecommitdiff
path: root/Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-07-02 08:46:23 -0700
committerpryazha <pryadeiniv@mail.ru>2025-07-02 08:46:23 -0700
commit8263edd59284aba390aca011d25b79efecef4c48 (patch)
tree6346e2afaaabd32156601cafaf20d4ee813befaf /Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs
Diffstat (limited to 'Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs')
-rw-r--r--Assets/Samples/XR Interaction Toolkit/3.1.2/Hands Interaction Demo/HandsDemoSceneAssets/Scripts/ToggleGameObject.cs47
1 files changed, 47 insertions, 0 deletions
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
+{
+ /// <summary>
+ /// Toggles the active state of a GameObject.
+ /// </summary>
+ public class ToggleGameObject : MonoBehaviour
+ {
+ [SerializeField]
+ [Tooltip("The GameObject to toggle the active state for.")]
+ GameObject m_ActivationGameObject;
+
+ /// <summary>
+ /// The GameObject to toggle the active state for.
+ /// </summary>
+ public GameObject activationGameObject
+ {
+ get => m_ActivationGameObject;
+ set => m_ActivationGameObject = value;
+ }
+
+ [SerializeField]
+ [Tooltip("Whether the GameObject is currently active.")]
+ bool m_CurrentlyActive;
+
+ /// <summary>
+ /// Whether the GameObject is currently active.
+ /// </summary>
+ public bool currentlyActive
+ {
+ get => m_CurrentlyActive;
+ set
+ {
+ m_CurrentlyActive = value;
+ activationGameObject.SetActive(m_CurrentlyActive);
+ }
+ }
+
+ /// <summary>
+ /// Toggles the active state of the GameObject.
+ /// </summary>
+ public void ToggleActiveState()
+ {
+ m_CurrentlyActive = !m_CurrentlyActive;
+ activationGameObject.SetActive(m_CurrentlyActive);
+ }
+ }
+}