68 lines
1.5 KiB
C#
68 lines
1.5 KiB
C#
|
|
using CameraSystem;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
using VRC.Udon.Common;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class CameraControllerBase : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private CameraSystem_Console _CameraConsole;
|
|
|
|
[UdonSynced] private int _ActiveCamera = -1;
|
|
|
|
|
|
public override void OnDeserialization(DeserializationResult Result)
|
|
{
|
|
_SwitchToLiveCamera_Synced();
|
|
|
|
base.OnDeserialization(Result);
|
|
}
|
|
|
|
|
|
public virtual void InitialiseCameras() { }
|
|
public virtual void DeinitialiseCameras()
|
|
{
|
|
DisableAllTriggers();
|
|
DisableAllSwitchers();
|
|
}
|
|
|
|
|
|
public void SwitchToLiveCamera(Camera SwitchTo)
|
|
{
|
|
for (int i = 0; i < _CameraConsole.camerasObjects.Length; i++)
|
|
{
|
|
if (_CameraConsole.camerasObjects[i] == SwitchTo)
|
|
{
|
|
_ActiveCamera = i;
|
|
_SwitchToLiveCamera_Synced();
|
|
RequestSerialization();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void DisableAllTriggers()
|
|
{
|
|
Debug.LogError("[CameraControllerBase] This function has not been reimplemented, or is called from a child class.");
|
|
}
|
|
|
|
public virtual void DisableAllSwitchers()
|
|
{
|
|
Debug.LogError("[CameraControllerBase] This function has not been reimplemented, or is called from a child class.");
|
|
}
|
|
|
|
|
|
private void _SwitchToLiveCamera_Synced()
|
|
{
|
|
if (_ActiveCamera >= 0 && _ActiveCamera < _CameraConsole.camerasObjects.Length)
|
|
{
|
|
Debug.Log("[CameraControllerBase] Switching to camera " + _ActiveCamera);
|
|
_CameraConsole.SendLiveCamera(_ActiveCamera);
|
|
}
|
|
}
|
|
}
|