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