using System.Collections; using System.Collections.Generic; using UnityEngine; using Snxxz.UI; public class CameraSwitch : MonoBehaviour { [SerializeField] GameObject m_CameraNode; bool cameraActive = true; bool check = false; int frameCount = 0; private void Awake() { WindowCenter.Instance.windowAfterOpenEvent += OnWindowOpen; WindowCenter.Instance.windowAfterCloseEvent += OnWindowClose; } private void OnDestroy() { WindowCenter.Instance.windowAfterOpenEvent -= OnWindowOpen; WindowCenter.Instance.windowAfterCloseEvent -= OnWindowClose; } private void OnWindowOpen(Window _window) { cameraActive = !WindowCenter.Instance.ExitAnyFullScreenOrMaskWin(); if (!cameraActive) { frameCount = 0; check = true; } else { m_CameraNode.gameObject.SetActive(cameraActive); } } private void OnWindowClose(Window _window) { cameraActive = !WindowCenter.Instance.ExitAnyFullScreenOrMaskWin(); if (!cameraActive) { frameCount = 0; check = true; } else { m_CameraNode.gameObject.SetActive(cameraActive); } } private void LateUpdate() { if (check) { frameCount++; if (frameCount == 3) { m_CameraNode.gameObject.SetActive(cameraActive); check = false; frameCount = 0; } } } }