using System.Collections; using System.Collections.Generic; using UnityEngine; public class WindowRoot : MonoBehaviour { public bool isAlwaysActive = true; public List active_TransList = new List(); public List notActive_TransList = new List(); public void SetActive(bool b) { if (this.gameObject.activeSelf != b) { this.gameObject.SetActive(b); } } public virtual void Init() { //当前窗口是否在启动时激活 if (isAlwaysActive) { SetActive(true); } else { SetActive(false); } //激活组件列表 for (int i = 0; i < active_TransList.Count; i++) { if (active_TransList[i] != null) { active_TransList[i].gameObject.SetActive(true); } } //待激活组件列表 for (int i = 0; i < notActive_TransList.Count; i++) { if (notActive_TransList[i] != null) { notActive_TransList[i].gameObject.SetActive(false); } } Debug.Log(this.gameObject.name); } }