原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/youxikaifa/2018/1129/215.html
Unity客户端架构-UIContainer
					继续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客户端架构-Util
下篇:下一篇:Unity客户端架构-io




