using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using vnxbqy.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.ExistAnyFullScreenOrMaskWin();
|
|
if (!cameraActive)
|
{
|
frameCount = 0;
|
check = true;
|
}
|
else
|
{
|
if(CameraController.Instance != null && CameraController.Instance.IsInGame)
|
m_CameraNode.SetActive(cameraActive);
|
}
|
}
|
|
private void OnWindowClose(Window _window)
|
{
|
cameraActive = !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin();
|
|
if (!cameraActive)
|
{
|
frameCount = 0;
|
check = true;
|
}
|
else
|
{
|
//防范意外的情况
|
if (CameraController.Instance != null && CameraController.Instance.IsInGame)
|
m_CameraNode.SetActive(cameraActive);
|
}
|
}
|
|
private void LateUpdate()
|
{
|
if (check)
|
{
|
frameCount++;
|
if (frameCount == 3)
|
{
|
m_CameraNode.SetActive(cameraActive);
|
check = false;
|
frameCount = 0;
|
}
|
}
|
}
|
|
|
|
}
|