Unity客户端架构-UIContainer

来源:互联网 发布:天猫优质男装品牌知乎 编辑:程序博客网 时间:2024/05/17 04:56
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;    }}
0 0
原创粉丝点击