Esempio n. 1
0
        private static void EndLoadComparison(byte[] data, object param)
        {
            if (data == null)
            {
                return;
            }

            string prefix = (string)param;

            ZLText zlt = new ZLText(data);
            Dictionary <string, List <string> > zlt_data = zlt.ReadAll();

            zlt = null;

            LoadData(prefix + ".bytes", zlt_data);
        }
Esempio n. 2
0
        public static void Init()
        {
            bool atlasDataInited = false;
            bool labelDataInited = false;
            bool fontInited      = false;

            if (!uiRootTrans)
            {
                GameObject go = GameObject.Find("UI Root");
                if (go == null)
                {
                    Debugger.LogError("UI Root is null");
                    return;
                }

                Object.DontDestroyOnLoad(go);

                uiRootTrans = go.transform;

                Transform camTrans = uiRootTrans.Find("Camera");
                if (camTrans == null)
                {
                    Debugger.LogError("Cam trans is null");
                    return;
                }

                _camera   = camTrans.GetComponent <Camera>();
                _uiCamera = camTrans.GetComponent <UICamera>();
            }
            else
            {
                fontInited = true;
            }

            System.Action checkOver = () =>
            {
                if (atlasDataInited && labelDataInited && fontInited)
                {
                    List <string> atlases;
                    if (!uiInfo.TryGetValue(UIATLASENAMES, out atlases))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UIATLASENAMES);
                        return;
                    }

                    List <string> textures;
                    if (!uiInfo.TryGetValue(UITEXTURENAMES, out textures))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UITEXTURENAMES);
                        return;
                    }

                    UIFrame.Init(atlases, textures);
                    uiInfo.Remove(UIATLASENAMES);
                    uiInfo.Remove(UITEXTURENAMES);

                    Debugger.Log("UI Init Over");
                    MessagePool.CSSendMessage(null, MessagePool.UIInitOver, Message.FilterTypeNothing, null);
                }
            };

            if (!fontInited)
            {
                ResLoader.LoadByName("MSYH", (asset, param) =>
                {
                    if (asset == null)
                    {
                        Debugger.Log("init font failed");
                        return;
                    }

                    comFont = ((GameObject)asset).GetComponent <UIFont>();
                    if (comFont == null)
                    {
                        Debugger.Log("font data not contains UIFont");
                        return;
                    }

                    UIFrame.SetFont(comFont);

                    fontInited = true;

                    checkOver();
                }, null);
            }

            ResLoader.AsynReadBytesByName(UIATLASDATAFILE, (arr, param) =>
            {
                if (arr == null)
                {
                    Debugger.LogError("init UI atlas data failed");
                    return;
                }

                ZLText zlt = new ZLText(arr);
                uiInfo     = zlt.ReadAll();
                zlt.Dispose();

                atlasDataInited = true;

                checkOver();
            }, null, true);

            ResLoader.AsynReadUTF8ByName(UILABELTEXTFILE, (str, param) =>
            {
                if (str == null)
                {
                    Debugger.LogError("init UI label text data failed");
                    return;
                }

                string[] lines = null;
                int index      = str.IndexOf("\r\n");
                if (index >= 0)
                {
                    lines = str.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);
                }
                else
                {
                    lines = str.Split(new string[] { "\n" }, System.StringSplitOptions.None);
                }

                labelTextData.AddRange(lines);
                labelDataInited = true;

                checkOver();
            }, null, true);
        }