Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        void DoCheck()
        {
            string verFile = PathUtils.GetVaildFullPath("version.json");

            m_verRes = SerializeHelper.LoadFromFile <VersionRes>(verFile);

            //这个大版本要写在程序里,才能保证获取的本地当前版本是对的!!!
            string[] programVersion = VersionResDef.version.Split('.');

            string[] oldVersion  = VersionUpdate.GetIns().GetVersion().Split('.');
            string[] newVersion  = m_verRes.version.Split('.');
            string[] miniVersion = m_verRes.miniVersion.Split('.');

            //强制更新apk,ios
            if (int.Parse(programVersion[0]) < int.Parse(miniVersion[0]) ||
                int.Parse(programVersion[1]) < int.Parse(miniVersion[1])
                )
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    DownloadMgr.GetInst().CreateTask(m_verRes.apk, m_verRes.apkSignature, DownloadApkResult);
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    //todo...
                }
                else
                {
                    //todo...
                }
                return;
            }

            int oldBigVersion = int.Parse(programVersion[0]);
            int newBigVersion = int.Parse(newVersion[0]);

            if (newBigVersion > oldBigVersion)
            {
                //todo...可选更新apk,ios
            }

            VersionUpdate.GetIns().SetVersion(m_verRes);
            m_mgr.ChangeNextStatus();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        public void Init()
        {
            m_statusMgr.RegisterStatus(new AppChannelStatus());
            m_statusMgr.RegisterStatus(new GameVersionStatus());
            m_statusMgr.RegisterStatus(new ResDownloadStatus());
            m_statusMgr.RegisterStatus(new GameStatus());

            DownloadMgr.GetInst().Init();
            m_statusMgr.Init();

            string verFile = PathUtils.GetVaildFullPath("version.json");

            if (verFile.Length > 0)
            {
                m_verRes = SerializeHelper.LoadFromFile <VersionRes>(verFile);
            }

            if (m_verRes == null)
            {
                LogUtils.LogError("verFile can not find!");
                return;
            }
        }
Ejemplo n.º 5
0
 public void SetVersion(VersionRes ver)
 {
     m_verRes = ver;
 }