blob: ac7f7e3807e65a488c7026a83c2fbdc4159346f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
}
}
}
|