CarmenSandiego/Assets/UdonSharp/Cameras/CameraControllerBase.cs
Jamie Greunbaum 0092bf0767 - Fixed line thicknesses for floor maps.
- Fixed a camera issue with reloading a round while round 1 is playing video.
- Modem now uses a slightly rougher metal material.
- Round 1 and 3 have better handling for switching cameras from video players.
- Added a method for checking if a GameManager is initialised.
- Added camera switch timers for round 3 ending video and game end.
- Added CameraAnchor tracking for waist-down targeting.
- Added a method to CameraTimedSwitcher to retrieve a defined switch time.
2026-04-14 22:36:27 -04:00

89 lines
1.9 KiB
C#

using CameraSystem;
using UdonSharp;
using UnityEngine;
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);
}
}
}