示例#1
0
    public void LoadPage(UIID uid)
    {
        if (ui_dict_all.ContainsKey(uid))
        {
            Debug.LogWarning("UI duplicate: " + uid + " already exists.");
            return;
        }

        if (!ui_config_table.ContainsKey(uid))
        {
            Debug.LogError("Load UI fails: " + uid + " is not found in ui config table.");
            return;
        }

        string path = ui_config_table[uid];
        //UIPage page = Resources.Load<UIPage>(path);
        GameObject assetObj = uiBundle.LoadAsset(uid.ToString() + ".prefab") as GameObject;
        UIPage     page_obj = assetObj.GetComponent <UIPage>();

        if (page_obj == null)
        {
            Debug.LogError("Load UI asset fails: " + uid + " cannot be loaded.");
            return;
        }
        UIPage page = Instantiate(page_obj, this.transform);

        page.Hide();
        ui_dict_all.Add(uid, page);
    }
示例#2
0
        public static UIData GetUIData(UIID uiId)
        {
            UIData thisUIData;

            if (UIDataTableDic.TryGetValue(uiId, out thisUIData))
            {
                return(thisUIData);
            }

            DebugMgr.LogError(uiId.ToString() + "Don't init!");
            return(null);
        }
示例#3
0
        private BasePanel LoadPanel(UIID panelName)
        {
            string     uiPath         = null;
            GameObject cloneUIPrefabs = null;
            BasePanel  basePanel      = null;

            m_DicUIPrefabPath.TryGetValue(panelName, out uiPath);
            if (!string.IsNullOrEmpty(uiPath))
            {
                //Test  需要重新改成ab
                Log.i("加载" + panelName);
                cloneUIPrefabs      = Instantiate(Resources.Load(uiPath)) as GameObject;//通过名称路径加载预设的克隆体
                cloneUIPrefabs.name = panelName.ToString();
            }

            if (root != null && cloneUIPrefabs != null)
            {
                basePanel = cloneUIPrefabs.GetComponent <BasePanel>();
                if (basePanel == null)
                {
                    Log.e("UIPrefab is null! Plz check UIPrefab!");
                    return(null);
                }
                switch (basePanel.formType)
                {
                case UIFormType.Normal:
                    cloneUIPrefabs.transform.SetParent(normalRoot, false);
                    break;

                case UIFormType.Fixed:
                    cloneUIPrefabs.transform.SetParent(fixedRoot, false);
                    break;

                case UIFormType.PopUp:
                    cloneUIPrefabs.transform.SetParent(popupRoot, false);
                    break;

                case UIFormType.None:
                    break;
                }
                cloneUIPrefabs.SetActive(false);
                m_DicAllPanel.Add(panelName, basePanel);
                return(basePanel);
            }
            else
            {
                Log.e("root or cloneUIPrefab is null!Plz check panelName=" + panelName);
            }
            return(null);
        }
示例#4
0
        /// <summary>
        /// 直接打开窗口
        /// </summary>
        protected void ShowUIForBack(UIID id)
        {
            if (!this.IsUIInControl(id))
            {
                Debug.Log("UIManager has no control power of " + id.ToString());
                return;
            }
            if (shownUIs.ContainsKey(id))
            {
                return;
            }

            UIBase baseUI = GetGameUI(id);

            baseUI.ShowUI();
            shownUIs[baseUI.GetID] = baseUI;
        }
示例#5
0
        protected virtual void CheckDirectlyHide(UIID id, Action onCompleted)
        {
            if (!IsUIInControl(id))
            {
                Debug.Log("UIManager has no control power of " + id.ToString());
                return;
            }
            if (shownUIs.ContainsKey(id))
            {
                return;
            }

            if (!isNeedWaitHideOver)
            {
                if (onCompleted != null)
                {
                    onCompleted();
                }
                shownUIs[id].HideUI(null);
                shownUIs.Remove(id);
                return;
            }

            if (shownUIs.ContainsKey(id))
            {
                if (onCompleted != null)
                {
                    onCompleted += delegate
                    {
                        shownUIs.Remove(id);
                    };
                    shownUIs[id].HideUI(onCompleted);
                }
                else
                {
                    shownUIs[id].HideUI(onCompleted);
                    shownUIs.Remove(id);
                }
            }
        }
示例#6
0
        public void OpenPanelTop(UIID uiID, params object[] args)
        {
            AbstractPanel panel = null;

            if (!m_AllPanelMap.TryGetValue(uiID, out panel))
            {
                panel = GetPanel(uiID);
                panel.PanelInit();
                if (panel == null)
                {
                    Log.I("No find panel:{0}", uiID.ToString());
                    return;
                }
            }
            panel.transform.SetParent(m_UIRoot.TopRoot);

            if (!m_CurrentShowMap.ContainsValue(panel))
            {
                m_CurrentShowMap.Add(uiID, panel);
            }
            m_CurrentShowList.Add(panel);
            panel.PanelOpen(args);
        }
示例#7
0
        public void OpenPanel(UIID uiID, params object[] args)
        {
            AbstractPanel panel = null;

            if (!m_AllPanelMap.TryGetValue(uiID, out panel))
            {
                panel = GetPanel(uiID);
                panel.PanelInit();
                if (panel == null)
                {
                    Log.I("No find panel:{0}", uiID.ToString());
                    return;
                }
            }
            panel.SortIndex = m_UIRoot.RequireNextPanelSortingOrder(panel.ShowMode);
            AdjustSiblingIndex(panel);
            if (!m_CurrentShowMap.ContainsValue(panel))
            {
                m_CurrentShowMap.Add(uiID, panel);
            }
            m_CurrentShowList.Add(panel);
            panel.PanelOpen(args);
        }
 private GameObject GetUIObejct(UIID id)
 {
     if (!_uiGameObjectsDic.ContainsKey(id) || _uiGameObjectsDic[id] == null)
     {
         GameObject prefab = LoadManager.Instance.Load <GameObject>(Path.UIPath, id.ToString());
         if (prefab != null)
         {
             _uiGameObjectsDic[id] = Instantiate(prefab);
         }
         else
         {
             Debug.LogError("can not find prefab name:" + id);
         }
     }
     return(_uiGameObjectsDic[id]);
 }