protected void _OnDownloadComplete(string error, byte[] data) { m_state = EnumJobState.Done; if (data == null) { return; } var name = m_curDownload; m_manager.AssetInfoManager.SetLocation(name, EnumFileLocation.Client); //保存下载文件 var path = XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix); XUtilities.SaveFile($"{path}/{name}", data); var hotfixInfo = m_manager.AssetInfoManager.hotfixInfo; //保存filelist var client_filelist = hotfixInfo.client_filelist; var server_filelist = hotfixInfo.server_filelist; var serverFileInfo = server_filelist.GetFileInfo(name); var clientFileInfo = client_filelist.GetFileInfo(name); if (clientFileInfo == null) { clientFileInfo = new XFileList.XFileInfo(); client_filelist.AddFileInfo(name, clientFileInfo); } clientFileInfo.name = name; clientFileInfo.path = serverFileInfo.path; clientFileInfo.length = serverFileInfo.length; clientFileInfo.md5 = serverFileInfo.md5; XFileList.SaveFileList(XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix), client_filelist); }
public void Reset() { client_filelist = null; download_size = 0L; download_list.Clear(); deleteXX_list.Clear(); }
//设置热更信息 protected void _UpdateHotfixInfo(XABAssetInfoManager.HotfixInfo hotfixInfo, XFileList server, XFileList client, XFileList origin) { //服务器清单 var serverDatas = server.GetDatas(); //客户端清单 var clientDatas = client.GetDatas(); //原始清单 var originDatas = origin.GetDatas(); hotfixInfo.Reset(); hotfixInfo.client_filelist = client; hotfixInfo.server_filelist = server; hotfixInfo.origin_filelist = origin; //检查更新资源 foreach (var fileInfo in serverDatas.Values) { var fileName = fileInfo.name; if (clientDatas.ContainsKey(fileInfo.name) && clientDatas[fileName].md5 == fileInfo.md5) { continue; } if (originDatas.ContainsKey(fileInfo.name) && originDatas[fileName].md5 == fileInfo.md5) { continue; } hotfixInfo.download_list.Add(fileName); hotfixInfo.download_size += fileInfo.length; } //检查删除资源 foreach (var fileInfo in clientDatas.Values) { var fileName = fileInfo.name; if (serverDatas.ContainsKey(fileName)) { continue; } hotfixInfo.deleteXX_list.Add(fileName); } }
public override void Enter() { var assetInfoManager = m_manager.AssetInfoManager; m_serverAddress = m_manager.serverAddress; #if UNITY_EDITOR m_serverAddress = EditorPrefs.GetString(XABConst.EKResUrl); if (string.IsNullOrEmpty(m_serverAddress)) { Debug.LogError("没有配置url"); return; } m_serverAddress += "/_filelist.json"; #endif m_server_filelist = null; m_client_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Client, EnumBundleType.Hotfix)); m_origin_filelist = XFileList.LoadFileList(XABUtilities.GetResPath(EnumFileLocation.Stream, EnumBundleType.Hotfix)); if (m_client_filelist == null) { m_client_filelist = new XFileList(); } if (m_origin_filelist == null) { m_origin_filelist = new XFileList(); } XWebRequestManagerSingle.GetUrl(m_serverAddress, delegate(string error, string responseData) { if (!string.IsNullOrEmpty(error)) { return; } m_server_filelist = JsonUtility.FromJson <XFileList>(responseData); XDebug.Log(XABConst.Tag, m_server_filelist.ToLog()); }); }
private void OnGUI() { //设置包名 if (GUILayout.Button("配置资源")) { var config = XUtilities.GetOrCreateConfig <EditorXABSettingConfig>(EditorXABSettingConfig.AssetPath); Selection.activeObject = config; } if (GUILayout.Button("更新包名")) { var config = XUtilities.GetOrCreateConfig <EditorXABSettingConfig>(EditorXABSettingConfig.AssetPath); config.UpdateBundleName(); } var platform = (EnumPlatform)EditorPrefs.GetInt(XABConst.EKResBuildPlatform, XABConst.EKResBuildPlatformValue); EditorGUI.BeginChangeCheck(); platform = (EnumPlatform)EditorGUILayout.EnumPopup("选择平台", platform); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(XABConst.EKResBuildPlatform, (int)platform); } //设置打包路径 var buildPath = EditorPrefs.GetString(XABConst.EKResBuildPath, XABConst.EKResBuildPathValue); EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); EditorGUILayout.TextField("输出路径", buildPath); if (GUILayout.Button("选择路径", GUILayout.Width(80))) { var sel = EditorUtility.OpenFolderPanel("选择路径", buildPath, string.Empty); if (!string.IsNullOrEmpty(buildPath)) { buildPath = sel; } } if (GUILayout.Button("默认路径", GUILayout.Width(80))) { buildPath = XABConst.EKResBuildPathValue; } GUILayout.EndHorizontal(); GUILayout.Space(2); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetString(XABConst.EKResBuildPath, buildPath); } if (GUILayout.Button("打包")) { BuildAssetBundle(platform); //创建filelist var outputHotfix = EditorXAssetBundle.GetOutputHotfix(platform); XFileList.CreateFileList(outputHotfix); } GUILayout.BeginHorizontal(); if (GUILayout.Button("准备热更包(压缩)")) { var outputHotfix = EditorXAssetBundle.GetOutputHotfix(platform); XFileList.LoadFileList(outputHotfix); } if (GUILayout.Button("准备热更包(非压缩)")) { var outputHotfix = EditorXAssetBundle.GetOutputHotfix(platform); XFileList.CreateFileList(outputHotfix); } GUILayout.EndHorizontal(); if (GUILayout.Button("打开目录")) { var output = EditorXAssetBundle.GetOutput(platform); Debug.Log(output); output = output.Replace("/", "\\"); System.Diagnostics.Process.Start("explorer.exe", output); } }