using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; public enum IndicationStatus { Idle, Loading, LoadSuccess, LoadFailure } [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] public class VideoLoadIndicator : UdonSharpBehaviour { [UdonSynced] private string _Owner = null; [UdonSynced, FieldChangeCallback(nameof(IndicateStatus))] private IndicationStatus _IndicateStatus = IndicationStatus.Idle; private MeshRenderer _IndicatorMesh; void Start() { _IndicatorMesh = GetComponent(); _Owner = Networking.LocalPlayer.displayName; } public override void OnOwnershipTransferred(VRCPlayerApi Player) { _Owner = Player.displayName; RequestSerialization(); base.OnOwnershipTransferred(Player); } public string GetOwner() { return _Owner; } public IndicationStatus IndicateStatus { set { _IndicateStatus = value; switch(_IndicateStatus) { case IndicationStatus.Idle: _IndicatorMesh.material.SetColor("_Color", Color.black); break; case IndicationStatus.Loading: _IndicatorMesh.material.SetColor("_Color", Color.yellow); break; case IndicationStatus.LoadSuccess: _IndicatorMesh.material.SetColor("_Color", Color.green); break; case IndicationStatus.LoadFailure: _IndicatorMesh.material.SetColor("_Color", Color.red); break; } Debug.Log("[VideoLoadIndicator] Setting load status to " + (int)_IndicateStatus); RequestSerialization(); } get => _IndicateStatus; } }