RuralPowerCompetition_yizhe.../RuralPowerCompetition_yizheng1/Assets/Zion/Scripts/MicroSystem/CenterManage.cs

59 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class CenterManage : MonoBehaviour
{
/// <summary>
/// 设备名称
/// </summary>
public string DevName;
private List<ScreenBase> microScreens;
/// <summary>
/// 所有界面
/// </summary>
public /*static*/ List<ScreenBase> MicroScreens { get { if (microScreens == null) microScreens = GetComponentsInChildren<ScreenBase>(true).ToList();return microScreens; } }
/// <summary>
/// 切换的界面
/// </summary>
public /*static*/ Stack<ScreenBase> cutScreens = new Stack<ScreenBase>();
// Start is called before the first frame update
void Start()
{
//MicroScreens = GetComponentsInChildren<ScreenBase>(true).ToList();
//MicroScreens.ForEach(x => x.Init());
}
/// <summary>
/// 切换下一界面
/// </summary>
/// <param name="_nextScreen"></param>
public /*static*/ void CutNextScreen(ScreenBase _currentScreen,string _nextScreenName)
{
ScreenBase _nextScreen = MicroScreens.Find(x => x.ScreenName.Equals(_nextScreenName));
if (_nextScreen != null)
{
_currentScreen.gameObject.SetActive(false);
cutScreens.Push(_currentScreen);
_nextScreen.gameObject.SetActive(true);
}
}
/// <summary>
/// 返回上一界面
/// </summary>
public /*static*/ void BackLastScreen(ScreenBase _currentScreen)
{
if (cutScreens.Count > 0)
{
_currentScreen.gameObject.SetActive(false);
ScreenBase _nextScreem = cutScreens.Pop();
_nextScreem.gameObject.SetActive(true);
}
}
}