-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTimedStartAndEnd.cs
47 lines (38 loc) · 1.05 KB
/
TimedStartAndEnd.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
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class TimedStartAndEnd : UdonSharpBehaviour
{
public float timerLength;
public UdonBehaviour startTarget;
public string startEventName;
public UdonBehaviour endTarget;
public string endEventName;
private bool counting;
private float _timerCount;
void Start()
{
counting = false;
}
public void StartEvent()
{
Debug.Log("Starting timed event");
counting = true;
startTarget.SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, startEventName);
}
private void Update()
{
if (!Networking.IsMaster) return;
if (!counting) return;
_timerCount += Time.deltaTime;
if(_timerCount > timerLength)
{
Debug.Log("Ending timed event");
endTarget.SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, endEventName);
_timerCount = 0;
counting = false;
}
}
}