65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BigSpace.XRCore.Base;
|
|
using BigSpace.XRCore.Scene;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SceneChangeUIMgr : MonoSingleton<SceneChangeUIMgr>
|
|
{
|
|
public GameObject changSceneObj;
|
|
public Image changSceneUI;
|
|
|
|
//计时相关
|
|
bool isRunChangeAlpha = false; //是否开始渐变
|
|
float fadeDuration = 2f; //渐变持续时间
|
|
float currentAlpha = 0; //透明度值
|
|
bool isShowChangeSceneUI = false; //是否显示
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
//转场UI渐变(隐藏UI)
|
|
if (isRunChangeAlpha)
|
|
{
|
|
if (isShowChangeSceneUI)
|
|
{
|
|
currentAlpha += Time.deltaTime / fadeDuration;
|
|
changSceneUI.color = new Color(changSceneUI.color.r, changSceneUI.color.g, changSceneUI.color.b, currentAlpha);
|
|
if (currentAlpha >= 1)
|
|
{
|
|
isRunChangeAlpha = false;
|
|
changSceneObj.SetActive(false);
|
|
currentAlpha = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
currentAlpha -= Time.deltaTime / fadeDuration;
|
|
changSceneUI.color = new Color(changSceneUI.color.r, changSceneUI.color.g, changSceneUI.color.b, currentAlpha);
|
|
if (currentAlpha <= 0)
|
|
{
|
|
isRunChangeAlpha = false;
|
|
changSceneObj.SetActive(false);
|
|
currentAlpha = 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//显示转场景UI
|
|
public void ShowChangeSecneUI(bool isShowUI)
|
|
{
|
|
//changSceneObj.SetActive(true); ////旧UI相关
|
|
isShowChangeSceneUI = isShowUI;
|
|
isRunChangeAlpha = true;
|
|
}
|
|
}
|