using BigSpace.Logic; using BigSpace.XRCore.Base; using BigSpace.XRCore.Event; using BigSpace.XRCore.Video; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; public class UIPanelControll : MonoSingleton { public List ListUiImg; //计时相关 bool isRun = false; bool isRun2 = false; float waitTime = 5f; float waitTime2 = 3f; float runTime = 0; int nowIndex = 0; //当前下标 //是否是特殊版本 bool isSpecialVersion = true; //特殊版本轮流显示相关 float specialTimer = 0f; float specialWaitTime = 3f; int specialIndex = 0; //轮流显示的索引 0-3 void Start() { GlobalEventMgr.Listen(GameEvent.EventShowUI, GameDataManage_EventShowUI); GlobalEventMgr.Listen(GameEvent.EventShowUI, GameDataManage_EventShowUIBeforeLongbiao); } private void Update() { if (isSpecialVersion) { //每隔3秒轮流显示,ListUiImg[0],ListUiImg[1],ListUiImg[2],ListUiImg[3] specialTimer += Time.deltaTime; if (specialTimer >= specialWaitTime) { specialTimer = 0f; //隐藏上一个 ListUiImg[specialIndex].gameObject.SetActive(false); //切换到下一个 specialIndex = (specialIndex + 1) % 4; //显示当前 ListUiImg[specialIndex].gameObject.SetActive(true); } } else { if (isRun) { runTime += Time.deltaTime; if (runTime >= waitTime) { isRun = false; runTime = 0; ListUiImg[nowIndex].gameObject.SetActive(false); if (nowIndex == 0) { } } } if (isRun2) { runTime += Time.deltaTime; if (runTime >= waitTime2) { isRun2 = false; isRun = true; runTime = 0; ListUiImg[0].gameObject.SetActive(true); ListUiImg[8].gameObject.SetActive(false); GlobalEventMgr.Dispatch(GameEvent.EventPlayTimeline); } } } } void GameDataManage_EventShowUIBeforeLongbiao() { } void GameDataManage_EventShowUI(int index) { if (isSpecialVersion) { nowIndex = index; ListUiImg[8].gameObject.SetActive(true); } else { if (index == 0 || index == 7) { nowIndex = index; if (index == 0) { isRun2 = true; ListUiImg[8].gameObject.SetActive(true); } else { ListUiImg[nowIndex].gameObject.SetActive(true); } if (index != 7 && index != 0) isRun = true; else { if (index == 7) { waitTime = 5; isRun = true; } } } } } }