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

135 lines
3.2 KiB
C#

using BigSpace.Logic;
using BigSpace.XRCore.Event;
using BigSpace.XRCore.RunningScene;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartShowUICtr : MonoBehaviour
{
// public List<GameObject> ListObj;
public GameObject leaveBoxObj;
public GameObject box360;
public GameObject sceneTitle;
public GameObject Volume; //后效
GameObject dynamicObj;
GameObject staticObj;
//显示字的时间
bool oIsRun = false;
float oneWaitTime = 3f;
float oneRunTime = 0;
private void Awake()
{
dynamicObj = GameObject.Find("Dynamic");
staticObj = GameObject.Find("Static");
if (box360 != null)
{
box360.transform.position = new Vector3(10000,0,0);
}
if (dynamicObj != null)
{
dynamicObj.SetActive(false);
}
if (staticObj != null)
{
staticObj.SetActive(false);
}
if (leaveBoxObj != null)
{
leaveBoxObj.SetActive(false);
}
//for (int i = 0; i < ListObj.Count; i++)
//{
// ListObj[i].SetActive(false);
//}
}
// Start is called before the first frame update
void Start()
{
GlobalEventMgr.Listen(GameEvent.EventRestScenePosition, GameDataManage_EventRestScenePosition);
SetVolume(false);
//Debug.Log("开始显示UI"+ RunningSceneMgr.Instance._runningSceneData.id);
StartCoroutine(WaitingShowUI()); //显示UI
ChangSceneSphereMgr.Instance.ShowChangeSecne(false);//黑球变淡
}
private void Update()
{
if (oIsRun)
{
oneRunTime += Time.deltaTime;
sceneTitle.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 1;
sceneTitle.transform.LookAt(Camera.main.transform);
if (oneRunTime >= oneWaitTime)
{
oIsRun = false;
oneRunTime = 0;
sceneTitle.gameObject.SetActive(false);
}
}
}
void SetVolume(bool isShow)
{
if (Volume != null)
{
Volume.SetActive(isShow);
}
}
//恢复场景
void GameDataManage_EventRestScenePosition()
{
//for (int i = 0; i < ListObj.Count; i++)
//{
// ListObj[i].SetActive(true);
//}
if (dynamicObj != null)
{
dynamicObj.SetActive(true);
}
if (staticObj != null)
{
staticObj.SetActive(true);
}
if (leaveBoxObj != null)
{
leaveBoxObj.SetActive(true);
}
box360.transform.position = Vector3.zero;
SetVolume(true);
}
private void OnDestroy()
{
GlobalEventMgr.Remove(GameEvent.EventRestScenePosition);
}
IEnumerator WaitingShowUI()
{
yield return new WaitForSeconds(1f);
if (sceneTitle != null)
{
oIsRun = true;
oneRunTime = 0;
sceneTitle.SetActive(true);
}
else
{
GlobalEventMgr.Dispatch(GameEvent.EventShowUI, RunningSceneMgr.Instance._runningSceneData.id % 10000);
}
}
}