//保存平台版本信息
        private static void SavePlatformVersion(List <BuildTarget> targets)
        {
            if (targets == null || targets.Count == 0)
            {
                return;
            }

            PlatformVersionInfo platformInfo = new PlatformVersionInfo();

            platformInfo.Version   = _config.Version;
            platformInfo.Platforms = new List <string>();
            foreach (var item in targets)
            {
                platformInfo.Platforms.Add(item.ToString());
            }
            string json = JsonUtility.ToJson(platformInfo);

            //保存平台信息
            File.WriteAllText(Path.Combine(_config.BuildPath, _assetVersionTxt), json);
            //更新资源版本号 -- 保存配置文件
            _config.Version++;
            SaveConfig();
            //打开文件夹
            EditorUtility.OpenWithDefaultApp(_config.BuildPath);
        }
示例#2
0
        //http文本读取成功
        private void OnHttpReadTextSuccess(object sender, IEventArgs e)
        {
            HttpReadTextSuccessEventArgs ne = (HttpReadTextSuccessEventArgs)e;

            if (ne != null)
            {
                if (ne.Url == Path.Combine(GameMode.Resource.ResUpdatePath, _assetPlatformVersionText))
                {
                    PlatformVersionInfo assetPlatform = JsonUtility.FromJson <PlatformVersionInfo>(ne.Content);
                    string platformName = GetPlatformName();
                    if (assetPlatform.Platforms.Contains(platformName))
                    {
                        //更新远程资源的路径
                        GameMode.Resource.ResUpdatePath =
                            Path.Combine(GameMode.Resource.ResUpdatePath, platformName);
                        //读取远程的文本
                        string remotePath = Path.Combine(GameMode.Resource.ResUpdatePath, _assetVersionTxt);
                        GameMode.WebRequest.ReadHttpText(remotePath);
                    }
                }
                else
                {
                    _remoteVersion = JsonUtility.FromJson <AssetBundleVersionInfo>(ne.Content);
                    if (_remoteVersion == null)
                    {
                        Debug.LogError("Remote Version is null");
                        return;
                    }

                    //如果资源版本不一样 则更新资源
                    if (!CompareVersion())
                    {
                        //更新资源
                        UpdateResource();
                        //下载资源
                        DownloadResource();
                    }

                    //资源更新完成
                    _resourceUpdateDone = true;
                }
            }
        }