Files
PrinceOfGlory/Assets/Scripts/XRCore/Scene/ChangSceneSphereMgr.cs
kridoo 6e91a0c7f0 111
2025-09-15 17:32:08 +08:00

87 lines
2.8 KiB
C#

using BigSpace.Logic;
using BigSpace.XRCore.Event;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChangSceneSphereMgr : MonoSingleton<ChangSceneSphereMgr>
{
public GameObject changSceneObj;
private Renderer rend;
private Material sphereMaterial;
bool isRunChangeAlpha = false; //是否开始渐变
float currentAlpha = 0; //透明度值
bool isShowChangeSceneUI = false; //是否显示
bool isNeedToWhite = false; //是否要返回为白色(最后一次黑完要白回去)
void Start()
{
rend = changSceneObj.GetComponent<Renderer>();
sphereMaterial = rend.material;
}
void Update()
{
if (isRunChangeAlpha)
{
if (isShowChangeSceneUI)
{
currentAlpha += Time.deltaTime / GameDataManage.Instance.inFadeTime;
Color currentColor = new Color(0, 0,0, currentAlpha);
sphereMaterial.color = currentColor;
//Debug.Log("currentColor:" + currentColor);
if (currentAlpha >= 1)
{
isRunChangeAlpha = false;
//StartCoroutine(WaitingClose()); //这里为了出UI文字
currentAlpha = 1;
if (isNeedToWhite) //需要白回去
{
Debug.Log("这个需要白回去");
ShowChangeSecne(false);
isNeedToWhite = false;
GlobalEventMgr.Dispatch(GameEvent.EventRestScenePosition);//还原场景位置
GlobalEventMgr.Dispatch(GameEvent.EventSetHandMove, 2);
}
}
}
else
{
currentAlpha -= Time.deltaTime / GameDataManage.Instance.outFadeTime;
Color currentColor = new Color(0, 0, 0, currentAlpha);
sphereMaterial.color = currentColor;
//Debug.Log("222currentColor:" + currentColor);
if (currentAlpha <= 0)
{
isRunChangeAlpha = false;
changSceneObj.SetActive(false);
currentAlpha = 0;
}
}
}
}
public void ShowChangeSecne(bool isShowUI,bool isNeed = false)
{
Debug.Log("是什么操作:" + isShowUI);
changSceneObj.SetActive(true);
isShowChangeSceneUI = isShowUI;
isRunChangeAlpha = true;
isNeedToWhite = isNeed; //旧UI相关
}
//旧UI相关
//IEnumerator WaitingClose()
//{
// yield return new WaitForSeconds(0.5f);
// Debug.Log("隐藏头显黑球");
// changSceneObj.SetActive(false);
// yield return new WaitForSeconds(2.5f);
// Debug.Log("显示头显黑球");
// changSceneObj.SetActive(true);
//}
}