using UnityEngine; namespace PhxhSDK { public class CameraManager : Singlenton, IInitable { private Camera _mainCamera; public Camera MainCamera { get { if (_mainCamera == null) { _mainCamera = Camera.main; } return _mainCamera; } } public Camera UICamera { get { return UIRoot.Instance.UICamera; } } public Camera CreateCamera(string name, string tag = null) { var go = new GameObject(name); var camera = go.AddComponent(); if (tag != null) { camera.tag = tag; } return camera; } public void DestroyCamera(Camera camera) { if (camera != null) { GameObject.Destroy(camera.gameObject); } } public void ReRenderAll() { foreach (var c in Camera.allCameras) { var oldEnabled = c.enabled; c.enabled = true; c.Render(); c.enabled = oldEnabled; } } public void Init() { if (MainCamera == null) { CreateCamera("Main Camera", "MainCamera"); } if (MainCamera != null) { GameObject.DontDestroyOnLoad(MainCamera.gameObject); } } public void Release() { } } }