-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEnableInArea.cs
More file actions
43 lines (37 loc) · 1.05 KB
/
EnableInArea.cs
File metadata and controls
43 lines (37 loc) · 1.05 KB
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
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class EnableInArea : UdonSharpBehaviour
{
[Header("Area based enable / disable")]
[Tooltip("Enables the objects when the user is inside the area, then disables when they leave.")]
public GameObject[] objects;
public bool statusWhenInsideArea;
void Start()
{
foreach (var item in objects)
{
item.SetActive(!statusWhenInsideArea);
}
}
public override void OnPlayerTriggerEnter(VRCPlayerApi player)
{
if (player != Networking.LocalPlayer) return;
//Debug.Log("OnPlayerTriggerEnter triggered");
foreach (var item in objects)
{
item.SetActive(statusWhenInsideArea);
}
}
public override void OnPlayerTriggerExit(VRCPlayerApi player)
{
if (player != Networking.LocalPlayer) return;
//Debug.Log("OnPlayerTriggerExit triggered");
foreach (var item in objects)
{
item.SetActive(!statusWhenInsideArea);
}
}
}