Esempio n. 1
0
        public string Get(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                QLog.LogError("传入的多语言Key为空!!");
                return(string.Empty);
            }
            string value;

            if (LanguageDict.TryGetValue(key, out value))
            {
                return(value);
            }
            QLog.LogError(StringPool.Concat("没有找到对应的多语言Key = ", key));
            return(key);
        }
Esempio n. 2
0
        public static string GetPath(Transform child, Transform parent)
        {
            string path = string.Empty;

            if (child == null || parent == null || child.name == parent.name)
            {
                return(path);
            }
            Transform tmp = child;

            while (tmp != null)
            {
                if (tmp != parent)
                {
                    path = StringPool.Concat(tmp.name, "/", path);
                    tmp  = tmp.parent;
                }
                else
                {
                    break;
                }
            }
            return(path);
        }
Esempio 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);
        }