Exemplo n.º 1
0
        public bool init()
        {
            clean();
#if !UNITY_EDITOR && !UNITY_WEBGL
            //取得最新的语言
            Callback cb = onGetLocalize;
            StartCoroutine(FileEx.readNewAllBytesAsyn(
                               PStr.b(CLPathCfg.self.localizationPath).a(Localization.language).a(".txt").e(),
                               cb));
#endif

            return(initAtlas());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inits the streaming assets packge.
        /// 将流目录中优先需要加载的资源集解压到可读写目录
        /// </summary>
        /// <param name="onFinisInitStreaming">On finis init streaming.</param>
        public void initStreamingAssetsPackge(Callback onFinisInitStreaming)
        {
            this.onFinisInitStreaming = onFinisInitStreaming;
            // clean cache
#if UNITY_EDITOR
            if (CLCfgBase.self.isEditMode)
            {
                onFinisInitStreaming();
                return;
            }
#endif
            try
            {
                // 当版本不同时, clean cache
                if (string.Compare(Application.version, clientVersion) != 0)
                {
                    string path = Application.persistentDataPath;
                    // 先删掉目录下的文件
                    string[] fEntries = Directory.GetFiles(path);
                    foreach (string f in fEntries)
                    {
                        File.Delete(f);
                    }
                    // 再删掉所有文件夹
                    string[] dirEntries = Directory.GetDirectories(path);
                    foreach (string dir in dirEntries)
                    {
                        Directory.Delete(dir, true);
                    }
                    clientVersion = Application.version;
                }

                // 处理资源释放
                if (!File.Exists(hadPoc))
                {
                    string   path = "priority.r";
                    Callback cb   = onGetStreamingAssets;
                    StartCoroutine(FileEx.readNewAllBytesAsyn(path, cb));
                }
                else
                {
                    onFinisInitStreaming();
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
                onFinisInitStreaming();
            }
        }