Unity客户端架构-UIContainer
发表于2018-09-05
继续Unity客户端架构系列的介绍,上一篇中给大家介绍了Util的使用,这一篇我们就来看看UIContainer的使用。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
//UI容器
public class UIContainer : MonoBehaviour {
public GameObject loginPanel;
public GameObject mainPanel;
public GameObject fightPanel;
public GameObject duplicatePanel;
public GameObject WorldPanel;
public GameObject taskPanel;
public List<GameObject> panels = new List<GameObject>();
public List<GameObject> AllPanel
{
get
{
this.panels.Clear();
this.AddPanel(this.loginPanel);
this.AddPanel(this.mainPanel);
this.AddPanel(this.fightPanel);
this.AddPanel(this.duplicatePanel);
this.AddPanel(this.WorldPanel);
this.AddPanel(this.taskPanel);
return this.panels;
}
}
private void AddPanel(GameObject go)
{
if (go != null)
{
this.panels.Add(go);
}
}
public void ClearAll()
{
List<GameObject> all = AllPanel;
foreach (GameObject obj in all)
{
if (obj != null)
DestroyImmediate(obj, true);
}
panels.Clear();
}
public static UIContainer instance;
// Use this for initialization
void Start () {
UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
instance = this;
}
}
Unity客户端架构系列教程
