-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectStateSetter.cs
63 lines (60 loc) · 1.87 KB
/
ObjectStateSetter.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using UnityEngine;
using UdonSharp;
namespace UwUtils
{
[AddComponentMenu("UwUtils/Object State Setter")]
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class ObjectStateSetter : UdonSharpBehaviour
{
[Header("List of objects to toggle ON")]
[SerializeField] private GameObject[] toggleObjectsON;
[Header("List of objects to toggle OFF")]
[SerializeField] private GameObject[] toggleObjectsOFF;
private bool valid = true;
void Start()
{
if (toggleObjectsON.Length == 0 & toggleObjectsOFF.Length == 0)
{
valid = false;
Debug.LogError("[UwUtils/iStateSet.cs] Setup is invalid, check your references for object '" + gameObject.name + "'");
}
else
{
return;
}
}
public override void Interact()
{
foreach (GameObject toggleObject in toggleObjectsON)
{
toggleObject.SetActive(true);
}
foreach (GameObject toggleObject in toggleObjectsOFF)
{
toggleObject.SetActive(false);
}
}
public void _Invert()
{
foreach (GameObject toggleObject in toggleObjectsON)
{
toggleObject.SetActive(false);
}
foreach (GameObject toggleObject in toggleObjectsOFF)
{
toggleObject.SetActive(true);
}
}
public void _Switch()
{
foreach (GameObject toggleObject in toggleObjectsON)
{
toggleObject.SetActive(toggleObject.activeSelf);
}
foreach (GameObject toggleObject in toggleObjectsOFF)
{
toggleObject.SetActive(toggleObject.activeSelf);
}
}
}
}