CarmenSandiego/Assets/UdonSharp/Cameras/CameraControllerBase.cs
Jamie Greunbaum e485d0d992 - Modem camera transition now has zoom animations.
- Added a CameraAnchor and follower for the winning player in round 2.
- Round 2 now has a more reliable check for when the call ends.
- CameraAnchor can now follow different areas of a player's body.
- CameraTimedSwitcher can now choose to always reactivate when asked.
- Glass shatter effect now only works for hosts.
- CaseVideoSyncPlayer will no longer crash when skipping too fast in round 1.
- Fixed an erroneous camera switcher activation in round 3.
- Made a minor wording change to Eartha Brute's wanted poster.
2026-03-25 04:08:23 -04:00

91 lines
2.0 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;
private CameraTimedSwitcher _ActiveSwitcher = null;
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 void ActivateCameraSwitcher(CameraTimedSwitcher Switcher = null)
{
if (_ActiveSwitcher != null)
{
_ActiveSwitcher.Activate(false);
}
_ActiveSwitcher = Switcher;
if (_ActiveSwitcher != null)
{
_ActiveSwitcher.Activate(true);
}
}
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.");
}
public virtual void ForceDisableAllSwitchers()
{
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);
}
}
}