Beispiel #1
0
        static void MakeVersionConfig(string version, string url)
        {
            AssetBundle         manifestBundle = AssetBundle.LoadFromFile(outputPath + "/" + outputName);
            AssetBundleManifest manifest       = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest");

            string[] allBundle = manifest.GetAllAssetBundles();
            manifestBundle.Unload(false);

            VersionRes ver = new VersionRes();

            ver.version = version;
            ver.url     = url;

            {
                VersionResFile file = new VersionResFile();
                file.name      = bundleInfoFileName;
                file.signature = FileChecker.GetFileSignature(outputPath + "/" + bundleInfoFileName);
                file.compress  = "none";
                ver.versionResFile.Add(file);
            }

            {
                VersionResFile file = new VersionResFile();
                file.name      = assetInfoFileName;
                file.signature = FileChecker.GetFileSignature(outputPath + "/" + assetInfoFileName);
                file.compress  = "none";
                ver.versionResFile.Add(file);
            }

            for (int i = 0; i < allBundle.Length; ++i)
            {
                EditorUtility.DisplayProgressBar("MakeVersionConfig config", "handle...", (float)i / allBundle.Length);

                VersionResFile file = new VersionResFile();
                file.name      = allBundle[i];
                file.signature = FileChecker.GetFileSignature(outputPath + "/" + allBundle[i]);
                file.compress  = "none";
                ver.versionResFile.Add(file);
            }
            EditorUtility.ClearProgressBar();
            string persistentPath = Application.dataPath + "/../PersistentData/";

            SerializeHelper.SaveToFile(ver, persistentPath + "version.json", true);
        }
Beispiel #2
0
        public override void OnEnter(Status oldStatus)
        {
            LogUtils.Log("enter res file check and update status");

            //check
            VersionRes verRes = VersionUpdate.GetIns().GetVersionRes();

            DownloadMgr.GetInst().SetBaseURL(verRes.url);
            DownloadMgr.GetInst().SetMaxTaskNum(3);

            m_downloadFile.Clear();
            m_downloadSuccFile.Clear();
            for (int i = 0; i < verRes.versionResFile.Count; ++i)
            {
                VersionResFile resFile = verRes.versionResFile[i];

                if (resFile.resType == VersionResType.PreDownload)
                {
                    string fullPath = PathUtils.GetVaildFullPath(resFile.name);
                    if (fullPath.Length == 0 || !FileChecker.VerifyFileSignature(fullPath, resFile.signature))
                    {
                        m_downloadFile.Add(resFile.name);
                        DownloadMgr.GetInst().CreateTask(resFile.name, verRes.versionResFile[i].signature, DownloadResult);
                    }
                }
                else
                {
                    string fileName = PathUtils.GetPersistentPath() + resFile.name;
                    if (fileName.Length > 0 && File.Exists(fileName))
                    {
                        if (!FileChecker.VerifyFileSignature(fileName, resFile.signature))
                        {
                            File.Delete(fileName);
                        }
                    }
                }
            }
            CheckFinish();
        }