Skip to main content

FallbackCamera

A class in Root.Township, the global namespace.

Black, lowest-depth camera that switches on whenever there is no current PlayerController, so the screen is not left without a camera. A DontDestroyOnLoad singleton made by PlayerController.

Constructors​

MemberWhat it is
FallbackCamera()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

2 private and internal fields
MemberWhat it is
private Camera localCameraThe camera component this object turns on and off.
private static Logger loggerNLog logger for this class.

Methods​

MemberWhat it is
static FallbackCamera Create()Returns the existing instance or makes a new FallbackCamera GameObject with its camera, kept across scene loads.
4 private and internal methods
MemberWhat it is
private static Camera CreateCamera(GameObject gameObject)Adds a disabled camera that renders nothing (culling mask 0), clears to black and sits at depth -100.
private void OnCurrentPlayerControllerChanged(PlayerController controller)Handler for PlayerController.CurrentPlayerChanged; calls UpdateCamera.
private void Start()Subscribes to PlayerController.CurrentPlayerChanged.
private void UpdateCamera()Enables the camera only while PlayerController.Current is null, logging when that changes.