Ejemplo n.º 1
0
        protected IEnumerator UpdateAssetFromUrl(CUpdateList needUpdateLst, string downloadUrl)
        {
            updateNum     = 0;
            needUpdateNum = needUpdateLst.Count();
            string savePath, downloadPath, saveDir;

            base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_FILE_START);
            foreach (CUpdateListField field in needUpdateLst)
            {
                downloadPath = downloadUrl + field.Path;
                savePath     = CEnv.AssetPath + field.Path;

                saveDir = savePath.Substring(0, savePath.LastIndexOf('/'));

                updateNum++;
                base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_FILE_ACTION);

                using (UnityWebRequest request = UnityWebRequest.Get(downloadPath))
                {
                    yield return(request.Send());

                    if (request.isError || request.responseCode != 200)
                    {
                        base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_FILE_FAILD);
                        yield break;
                    }
                    CDirectory.CreateDir(saveDir);
                    CFile.Cover(savePath, request.downloadHandler.data, 0, request.downloadHandler.data.Length);
                }
            }

            base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_FILE_END);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取文件更新列表
        /// </summary>
        /// <returns></returns>
        protected IEnumerator UpdateList(string resUrl)
        {
            base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_START);
            resUrl = resUrl + "/" + CEnv.PlatformToName(CEnv.SwitchPlatform);
            UnityWebRequest request = UnityWebRequest.Get(resUrl + "/" + CUpdateList.FILE_NAME);

            yield return(request.Send());

            if (request.isError || request.responseCode != 200)
            {
                this.isUpdate = false;
                base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_LIST_FAILED);
                yield break;
            }

            base.Event.Trigger(CAutoUpdateEvents.ON_SCANNING_DISK_FILE_HASH_START);

            var newLst = new CUpdateList(request).SetPath(CEnv.AssetPath);

            CUpdateList oldLst = new CUpdateList(CEnv.AssetPath);

            CDirectory.CreateDir(CEnv.AssetPath);

            CDirectory.Walk(CEnv.AssetPath, (file) => {
                if (!file.Standard().EndsWith(".meta"))
                {
                    string fullName  = file.Standard();
                    string assetName = fullName.Substring(CEnv.AssetPath.Length);
                    oldLst.Append(assetName, CMD5.ParseFile(file), file.Length);
                }
            });

            base.Event.Trigger(CAutoUpdateEvents.ON_SCANNING_DISK_FILE_HASH_END);

            CUpdateList needUpdateLst, needDeleteLst;

            oldLst.Comparison(newLst, out needUpdateLst, out needDeleteLst);

            yield return(this.DeleteOldAsset(needDeleteLst));

            yield return(this.UpdateAssetFromUrl(needUpdateLst, resUrl));

            newLst.Save();

            base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_COMPLETE);
        }
Ejemplo n.º 3
0
        public static void BuildAllAssetBundles()
        {
            RuntimePlatform switchPlatform = CEnv.SwitchPlatform;
            string          platform       = CEnv.PlatformToName(switchPlatform);

            CCreateAssetBundles.ClearAssetBundle();
            CCreateAssetBundles.BuildAssetBundleName(CEnv.DataPath + CEnv.ResourcesBuildPath);

            string releasePath = CEnv.DataPath + CEnv.ReleasePath + "/" + platform;

            CDirectory.CreateDir(releasePath, CDirectory.Operations.EXISTS_TO_DELETE);
            BuildPipeline.BuildAssetBundles("Assets" + CEnv.ReleasePath + "/" + platform,
                                            BuildAssetBundleOptions.None,
                                            CCreateAssetBundles.PlatformToBuildTarget(switchPlatform));

            CCreateAssetBundles.BuildListFile(releasePath);

            AssetDatabase.Refresh();
        }