-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LoopToggle.cs
71 lines (60 loc) · 1.75 KB
/
LoopToggle.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
64
65
66
67
68
69
70
71
using UnityEngine;
using UdonSharp;
using UnityEngine.UI;
using VRC.SDKBase;
using VRC.SDK3.Video.Components.Base;
namespace UdonVR.Takato.VideoPlayer
{
public class LoopToggle : UdonSharpBehaviour
{
public UdonSyncVideoPlayer videoPlayer;
[UdonSynced] bool _loopSynced;
bool _loop;
public Toggle loopToggle;
private void ToggleValue(bool value)
{
Debug.Log("[UdonVR] LoopToggleValue!");
loopToggle.enabled = false;
loopToggle.isOn = value;
loopToggle.enabled = true;
}
public void Init()
{
_loopSynced = videoPlayer.videoPlayer.Loop;
_loop = _loopSynced;
ToggleValue(_loopSynced);
}
public void ToggleButton() //Call RunProgram on this method
{
Debug.Log("[UdonVR] LoopToggle!");
if (Networking.IsMaster)
{
_loopSynced = loopToggle.isOn;
DoToggle();
}
else
ToggleValue(_loopSynced);
}
private void DoToggle()
{
_loop = _loopSynced;
videoPlayer.avProVideoPlayer.Loop = _loopSynced;
videoPlayer.unityVideoPlayer.Loop = _loopSynced;
//videoPlayer.Loop = _loopSynced;
if (!Networking.IsMaster)
{
ToggleValue(_loopSynced);
}
}
public override void OnDeserialization()
{
if (!Networking.IsMaster)
{
if (_loop != _loopSynced)
{
DoToggle();
}
}
}
}
}