-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldJoin.cs
More file actions
50 lines (46 loc) · 1.23 KB
/
WorldJoin.cs
File metadata and controls
50 lines (46 loc) · 1.23 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
44
45
46
47
48
49
50
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
namespace UdonVR.Childofthebeast
{
public class WorldJoin : UdonSharpBehaviour
{
public AudioSource Bell;
public AudioClip Join;
public AudioClip Leave;
private bool JoinEnable = true;
private bool LeaveEnable = true;
private int _numPlayers;
private int _numJoins;
private void Start()
{
_numPlayers = VRCPlayerApi.GetPlayerCount();
}
public override void OnPlayerJoined(VRCPlayerApi player)
{
_numJoins = _numJoins + 1;
if (Join != null && JoinEnable && _numJoins > _numPlayers)
{
Bell.clip = Join;
Bell.Play();
}
}
public override void OnPlayerLeft(VRCPlayerApi player)
{
if (Leave != null && LeaveEnable)
{
Bell.clip = Leave;
Bell.Play();
}
}
public void JoinToggle()
{
JoinEnable = !JoinEnable;
}
public void LeaveToggle()
{
LeaveEnable = !LeaveEnable;
}
}
}