CarmenSandiego/Assets/UdonSharp/RandomVideoPlayer.cs
Jamie Greunbaum 359ef58a33 - Fixed a bug that caused the crook portrait to never update except on owner.
- Reduced polygon count of drywall meshes.
- Improved triangulation of the TV screen.
- Improved lightmaps, and reduce their size.
- Added video player to show Patty Larceny going to jail.
- Added temporary Patty In Jail tune.
- Added a new interface to the host card for these experimental features.
2025-08-23 04:52:48 -04:00

76 lines
1.5 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDK3.Video.Components.Base;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class RandomVideoPlayer : UdonSharpBehaviour
{
public VRCUrl[] VideoPool;
private BaseVRCVideoPlayer _VideoPlayer;
[UdonSynced, FieldChangeCallback(nameof(VideoIndex))] private int _VideoIndex = -1;
[UdonSynced, FieldChangeCallback(nameof(PlayVideo))] private bool _VideoIsPlaying;
void Start()
{
_VideoPlayer = GetComponent<BaseVRCVideoPlayer>();
}
public void LoadRandomVideo()
{
VideoIndex = Random.Range(0, VideoPool.Length);
}
private void _PlayVideo_Private()
{
_VideoPlayer.Play();
transform.position = new Vector3(transform.position.x, 0.0f, transform.position.z);
}
private void _StopVideo_Private()
{
transform.position = new Vector3(transform.position.x, 1000.0f, transform.position.z);
_VideoPlayer.Stop();
VideoIndex = -1;
}
public override void OnVideoEnd()
{
transform.position = new Vector3(transform.position.x, 1000.0f, transform.position.z);
base.OnVideoEnd();
}
public int VideoIndex
{
set
{
_VideoIndex = value;
if (VideoIndex >= 0)
{
_VideoPlayer.LoadURL(VideoPool[_VideoIndex]);
}
RequestSerialization();
}
get => _VideoIndex;
}
public bool PlayVideo
{
set
{
_VideoIsPlaying = value;
if (_VideoIsPlaying) _PlayVideo_Private();
else _StopVideo_Private();
RequestSerialization();
}
get => _VideoIsPlaying;
}
}