Exemplo n.º 1
0
        private void DoOver()
        {
            Debugger.LogError(">>>>>>>>>>>>>>>>>>>>>>Update Over<<<<<<<<<<<<<<<<<<<<<<<<<<");

            if (doCheckUF != null)
            {
                doCheckUF(1f);
            }

            SetFileLocate();

            over      = true;
            canUpdate = false;

            vfc         = null;
            versionInfo = null;
            if (needUpdateList != null)
            {
                needUpdateList.Clear();
                needUpdateList = null;
            }

            streamingAssetVersionInfo = null;

            if (doUpdateUIOver != null)
            {
                doUpdateUIOver();
                curFileSize = 0;
            }

            if (reMs != null)
            {
                reMs.Dispose();
                reMs = null;
            }

            //load newer lua
            LuaLoader.GetInstance().Reset();

            MessagePool.CSSendMessage(null, MessagePool.UpdateResOver, Message.FilterTypeNothing, "");

            //test
            Dictionary <string, RelationData> .Enumerator e = nameToRelation.GetEnumerator();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            while (e.MoveNext())
            {
                sb.Append(e.Current.Key);
                sb.Append("\r\n");
            }

            Debug.Log("all version files->" + sb.ToString());
        }
Exemplo 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);
        }