Ejemplo n.º 1
0
        public void Close()
        {
            UIBase lastUIBase;

            if (TryGetLastUIBase(out lastUIBase))
            {
                EUI eUI = lastUIBase.eUI;
                QLog.LogEditor(StringPool.Format("统一关闭 {0} .", eUI.ToString()));
                Close(eUI);
            }
        }
Ejemplo n.º 2
0
    public static UIBase CreateUI(EUI eUI)
    {
        if (dUIs.ContainsKey(eUI))
        {
            if (dUIs[eUI] != null)
            {
                return(dUIs[eUI]);
            }
            else
            {
                dUIs.Remove(eUI);
            }
        }

        Transform tr   = Resources.Load <Transform>("UI/" + eUI);
        Transform uiTr = null;

        if (tr == null)
        {
            //加载AssetBundle
        }
        else
        {
            uiTr = GameObject.Instantiate(tr) as Transform;
        }
        uiTr.name = eUI.ToString();

        UIBase ui = uiTr.GetComponent <UIBase>();

        if (ui == null)
        {
            ui = uiTr.gameObject.AddComponent(Type.GetType(eUI.ToString())) as UIBase;
        }
        ui.transform.localPosition = Vector3.zero;
        dUIs.Add(eUI, ui);
        return(ui);
    }
Ejemplo n.º 3
0
        public void Open(EUI eUI, EUIDepth eUIDepth = EUIDepth.Default, params object[] objs)
        {
            UIBase uIBase;

            if (TryGetUIBase(eUI, out uIBase))
            {
                QLog.LogWarning(StringPool.Concat("Already open UI, witch EUI is ", eUI.ToString()));
                return;
            }

            UIBase prefabDatabase = UnityEditor.AssetDatabase.LoadAssetAtPath <UIBase>(StringPool.Concat(PATH_PREFAB_UI, eUI.ToString(), ".prefab"));

            if (prefabDatabase == null)
            {
                QLog.LogError(StringPool.Concat("Can not find UIBase Script in EUI = ", eUI.ToString()));
                return;
            }

            uIBase = Object.Instantiate <UIBase>(prefabDatabase, UGUI.UGUICanvas.transform, false);
            if (uIBase == null)
            {
                QLog.LogError(StringPool.Concat("Instantiate fail, EUI = ", eUI.ToString()));
                return;
            }

            //设置数据,判断是否进入
            uIBase.SetData(objs);
            if (!uIBase.IsCanEnter())
            {
                QLog.Log(StringPool.Concat("The UIBase script can not enter, EUI = ", eUI.ToString()));
                return;
            }

            //取出最后的界面,执行OnPause函数
            UIBase lastUIBase;

            if (TryGetLastUIBase(out lastUIBase))
            {
                QLog.LogEditor(StringPool.Format("{0} 执行暂停函数", lastUIBase.eUI.ToString()));
                lastUIBase.OnPause();
            }

            uIBase.CacheGameObject.SetActive(true);

            //设置层级
            int tmpDepth;

            if (DepthPool.TryGetValue(eUIDepth, out tmpDepth))
            {
                tmpDepth           += DEPTH_BETWEEN_UI;
                DepthPool[eUIDepth] = tmpDepth;
            }
            else
            {
                tmpDepth += (int)eUIDepth + DEPTH_BETWEEN_UI;
                DepthPool.Add(eUIDepth, tmpDepth);
            }

            uIBase.SetDepth(eUI, eUIDepth, tmpDepth);
            QLog.LogEditor(StringPool.Format("{0} depth is {1}", uIBase.eUI.ToString(), tmpDepth.ToString()));


            //新界面,执行OnEnter函数
            QLog.LogEditor(StringPool.Format("{0} 执行OnEnter函数", uIBase.eUI.ToString()));
            uIBase.OnEnter();
            UIBasePool.Add(uIBase);
        }