public override void OnEnter(params object[] parameters) { base.OnEnter(parameters); GameMode.Event.AddListener <HttpResponseSuccessEventArgs>(OnHttpReadTextSuccess); GameMode.Event.AddListener <HttpResponseFailEventArgs>(OnHttpReadTextFail); GameMode.Event.AddListener <DownloadSuccessEventArgs>(OnDownloadSuccess); GameMode.Event.AddListener <DownloadFaileEventArgs>(OnDownloadFaile); GameMode.Event.AddListener <DownloadProgressEventArgs>(OnDownloadProgress); _localVersion = LoadLocalVersion(); LoadRemoteVersion(); }
//http文本读取成功 private void OnHttpReadTextSuccess(object sender, IEventArgs e) { HttpResponseSuccessEventArgs ne = (HttpResponseSuccessEventArgs)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.Get(remotePath).Send(); } } else { Debug.Log("CheckResourceState:RemoteVersion:" + ne.Content); _remoteVersion = JsonUtility.FromJson <AssetBundleVersionInfo>(ne.Content); if (_remoteVersion == null) { Debug.LogError("Remote Version is null"); return; } //如果资源版本不一样 则更新资源 if (!CompareVersion()) { //更新资源 UpdateResource(); //下载资源 DownloadResource(); } else { Debug.Log("No New Update!"); } //资源更新完成 _resourceUpdateDone = true; } } }
public override void OnEnter(params object[] parameters) { base.OnEnter(parameters); string localPath = Path.Combine(GameMode.Resource.LocalPath, "AssetVersion.txt"); AssetBundleVersionInfo versionInfo = JsonUtility.FromJson <AssetBundleVersionInfo>(File.ReadAllText(localPath)); //设置ab包的加载方式 GameMode.Resource.SetResourceHelper(new BundleResourceHelper()); //加载ab包的mainfest文件 GameMode.Resource.SetMainfestAssetBundle(versionInfo.ManifestAssetBundle, versionInfo.IsEncrypt); // 载入AB资源 LoadResourceAsync(); }
private AssetBundleUpdateInfo GenerateAssetBundleUpdateInfo(AssetBundleManifest manifest) { var versionInfo = new AssetBundleVersionInfo { MinorVersion = int.Parse(DateTime.Now.ToString("yyMMddHHmm")), MarjorVersion = CURRENT_VERSION_MAJOR }; versionInfo.Save(mAbBuildInfo.outputDirectory, mAbBuildInfo.isEncrypt); var assetBundleUpdateInfo = new AssetBundleUpdateInfo(versionInfo.MinorVersion, mAbBuildInfo.outputDirectory, manifest); assetBundleUpdateInfo.Save(mAbBuildInfo.outputDirectory, mAbBuildInfo.isEncrypt); return(assetBundleUpdateInfo); }
internal void SetBundleItem(IList <InspectTreeItem> selected) { m_VersionInspector.SetVersion(null); m_UpdateInfoInspector.SetUpdateInfo(null); m_SingleInspector.SetBundle(null); //m_SelectedBundleTreeItems = selected; if (selected == null || selected.Count == 0 || selected[0] == null) { m_SingleInspector.SetBundle(null); } else if (selected.Count == 1) { if (selected[0].displayName.EndsWith(AssetBundleVersionInfo.FILE_NAME)) { AssetBundleVersionInfo version = new AssetBundleVersionInfo(); version.Load(selected[0].bundlePath.Replace(AssetBundleVersionInfo.FILE_NAME, ""), m_IsEncrypt); m_VersionInspector.SetVersion(version); } else if (selected[0].displayName.EndsWith(AssetBundleUpdateInfo.FILE_NAME)) { AssetBundleUpdateInfo updateInfo = new AssetBundleUpdateInfo(); updateInfo.Load(selected[0].bundlePath.Replace(AssetBundleUpdateInfo.FILE_NAME, ""), m_IsEncrypt); m_UpdateInfoInspector.SetUpdateInfo(updateInfo); } else { AssetBundle bundle = LoadBundle(selected[0].bundlePath); m_SingleInspector.SetBundle(bundle, selected[0].bundlePath, m_Data, this); } } else { m_SingleInspector.SetBundle(null); //perhaps there should be a way to set a message in the inspector, to tell it... //var style = GUI.skin.label; //style.alignment = TextAnchor.MiddleCenter; //style.wordWrap = true; //GUI.Label( // inspectorRect, // new GUIContent("Multi-select inspection not supported"), // style); } }
internal void SetVersion(AssetBundleVersionInfo version) { //members mVersion = version; }