35 lines
730 B
C#
35 lines
730 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public static class LocalPlayerCameraRegistry
|
|
{
|
|
public static Camera Current { get; private set; }
|
|
|
|
public static event Action<Camera> Changed;
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
|
private static void ResetState()
|
|
{
|
|
Current = null;
|
|
Changed = null;
|
|
}
|
|
|
|
public static void Register(Camera camera)
|
|
{
|
|
if (camera == null || Current == camera)
|
|
return;
|
|
|
|
Current = camera;
|
|
Changed?.Invoke(Current);
|
|
}
|
|
|
|
public static void Unregister(Camera camera)
|
|
{
|
|
if (Current != camera)
|
|
return;
|
|
|
|
Current = null;
|
|
Changed?.Invoke(null);
|
|
}
|
|
}
|