Пример #1
0
        public BasePanel ShowPanel(string panelName)
        {
            BasePanel panel = GetPanel(panelName);

            if (panel != null)
            {
                panel.ShowPanel(null);
            }
            else
            {
                panel = LoadPanel(panelName);
                panel.ShowPanel(null);
            }
            return(panel);
        }
Пример #2
0
        public T ShowPanel <T>(object obj = null) where T : BasePanel
        {
            T t = GetPanel <T>();

            if (t != null)
            {
                t.ShowPanel(obj);
            }
            else
            {
                string    panelName = typeof(T).Name;
                BasePanel bp        = LoadPanel(panelName);
                if (bp != null)
                {
                    bp.ShowPanel(obj);
                    return(bp as T);
                }
            }
            return(t);
        }
Пример #3
0
        public T GetPanel <T>() where T : BasePanel
        {
            BasePanel panel = GetPanel(typeof(T).Name);

            if (panel != null)
            {
                return(panel as T);
            }
            else
            {
                string    panelName = typeof(T).Name;
                BasePanel bp        = LoadPanel(panelName);
                if (bp != null)
                {
                    return(bp as T);
                }
            }

            return(null);
        }
Пример #4
0
        BasePanel InstantiateObj(string panelName)
        {
            GameObject obj = GetGameObjectByPanelName(panelName);

            Debug.Log("load ui panel " + obj.name);
            if (obj == null)
            {
                return(null);
            }

            GameObject go = GameObject.Instantiate(obj) as GameObject;

            go.name = panelName;
            BasePanel bp = go.GetComponent <BasePanel>();

            if (bp == null)
            {
                go.AddComponent <BasePanel>();
            }

            return(bp);
        }