public static void ExportBundlesEx() { ExportScenesManager.AutoSwitchTarget(); var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath)); //if (files.Length != 0) //{ var currentVersion = new VersionCodeInfo("0.0.0.1"); foreach (var item in dirs) { var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name); if (fileVersion.Compare(currentVersion) > 0) { currentVersion = fileVersion; } } //var m_currentVersion = currentVersion.GetLowerVersion(); var m_newVersion = currentVersion.ToString(); var m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/"); var targetPath = m_newVersionFolder + BuildProjectExWizard.ExportFilesPath; var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); var paths = (from s in selection let path = AssetDatabase.GetAssetPath(s) where File.Exists(path) select path).ToArray(); foreach (string item in paths) { Debug.Log("ex " + item); ExportBundle(new string[] { item }, targetPath); } }
public VersionManagerInfo() { ProgramVersionCodeInfo = new VersionCodeInfo("0.0.0.1"); ResourceVersionCodeInfo = new VersionCodeInfo("0.0.0.0"); PackageList = string.Empty; PackageUrl = string.Empty; }
public void AsynDownloadUpdatePackage(Action <bool> fileDecompress, VersionCodeInfo serverVersion, VersionCodeInfo localVersion, Dictionary <String, String> packageMD5Dic, String packageUrl, string packageMd5List, Action <int, int, string> taskProgress, Action <int, long, long> progress, Action finished, Action <Exception> error, bool isFirstRes = false, bool forFullPkg = false) { LoggerHelper.Debug("下载包列表"); DownloadPackageInfoList(packageMd5List, (packageInfoList) => { var downloadList = (from packageInfo in packageInfoList where packageInfo.LowVersion.Compare(localVersion) >= 0 && packageInfo.HighVersion.Compare(serverVersion) <= 0 select new KeyValuePair <string, string>(packageInfo.HighVersion.ToString(), packageInfo.Name)).ToList(); if (downloadList.Count != 0) { LoggerHelper.Debug("开始下载包列表"); DownDownloadPackageList(fileDecompress, packageUrl, downloadList, packageMD5Dic, taskProgress, progress, finished, error, isFirstRes, forFullPkg); } else { LoggerHelper.Debug("更新包数目为0"); if (finished != null) { finished(); } } }, () => { error(new Exception("DownloadPackageInfoList error.")); }, isFirstRes); }
public VersionManagerInfo() { ProgramVersionInfo = new VersionCodeInfo("0.0.0.1"); ResourceVersionInfo = new VersionCodeInfo("0.0.0.0"); FirstResourceVersionInfo = new VersionCodeInfo("0.0.0.0"); FullResourceVersionInfo = new VersionCodeInfo("0.0.0.0"); PackageUrl = String.Empty; ApkUrl = String.Empty; ExportSwitch = false; IsPlatformUpdate = true; IsOpenUrl = false; }
public int Compare(VersionCodeInfo info) { int num = (this.m_tags.Count < info.m_tags.Count) ? this.m_tags.Count : info.m_tags.Count; for (int i = 0; i < num; i++) { if (this.m_tags[i] != info.m_tags[i]) { return((this.m_tags[i] > info.m_tags[i]) ? 1 : -1); } } return(0); }
/// <summary> /// 比较版本号,自己大返回1,自己小返回-1,一样返回0 /// </summary> /// <param name="codeInfo"></param> /// <returns></returns> public int Compare(VersionCodeInfo codeInfo) { int count = this.m_listCodes.Count < codeInfo.m_listCodes.Count ? this.m_listCodes.Count : codeInfo.m_listCodes.Count; for (int i = 0; i < count; i++) { if (this.m_listCodes[i] == codeInfo.m_listCodes[i]) { continue; } else { return(this.m_listCodes[i] > codeInfo.m_listCodes[i] ? 1 : -1); } } return(0); }
/// <summary> /// 比较版本号,自己比参数大,返回1,比参数小,返回-1,相等返回0。 /// </summary> /// <param name="info">比较版本号。</param> /// <returns>自己比参数大,返回1,比参数小,返回-1,相等返回0。</returns> public int Compare(VersionCodeInfo info) { var count = this.m_tags.Count < info.m_tags.Count ? this.m_tags.Count : info.m_tags.Count; for (int i = 0; i < count; i++) { if (this.m_tags[i] == info.m_tags[i]) { continue; } else { return(this.m_tags[i] > info.m_tags[i] ? 1 : -1); } } return(0); }
public VersionCodeInfo GetUpdatingCodeInfo(string json) { VersionCodeInfo NowLineCodeInfo = JsonHelper.FromJson <VersionCodeInfo>(json); return(NowLineCodeInfo); }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { EditorGUIUtility.LookLikeControls(80f); scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.BeginHorizontal(); GUILayout.Label("比对版本号:", GUILayout.Width(120f)); m_currentVersion = GUILayout.TextField(m_currentVersion); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("目标版本号:", GUILayout.Width(120f)); m_newVersion = GUILayout.TextField(m_newVersion); GUILayout.EndHorizontal(); if (GUILayout.Button("提升版本", GUILayout.Width(120f))) { BundleExporter.ClearDependenciesDic(); m_currentVersion = new VersionCodeInfo(m_currentVersion).GetUpperVersion(); m_newVersion = new VersionCodeInfo(m_newVersion).GetUpperVersion(); var curVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_currentVersion).Replace("\\", "/"); m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/"); ExportScenesManager.DirectoryCopy(curVersionFolder, m_newVersionFolder, true); } NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUILayout.Label("选择打包资源:", GUILayout.Width(120f)); bool tempAll = m_selectAll; m_selectAll = GUILayout.Toggle(tempAll, "全选"); GUILayout.EndHorizontal(); if (m_buildResourcesInfoList != null) foreach (var item in m_buildResourcesInfoList) { NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); bool temp = item.check; bool hasChanged = false; if (m_selectAll != tempAll) item.check = m_selectAll; item.check = GUILayout.Toggle(item.check, item.name); GUILayout.Label(item.type, GUILayout.Width(100f)); foreach (var ex in item.extentions) { GUILayout.Label(ex, GUILayout.Width(100f)); } hasChanged = temp != item.check; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); foreach (var folder in item.folders) { if (hasChanged) folder.check = item.check; folder.check = GUILayout.Toggle(folder.check, folder.path); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("导出资源EX", GUILayout.Width(120f))) { var targetPath = m_newVersionFolder + ExportFilesPath; BuildAssetBundleMainAsset(item, targetPath); } if (GUILayout.Button("生成资源版本", GUILayout.Width(120f))) { var sw = new Stopwatch(); sw.Start(); var rootPath = Path.Combine(m_newVersionFolder, "version").Replace("\\", "/"); if (item.check) BuildAssetVersion(item, rootPath); sw.Stop(); LoggerHelper.Debug("BuildAssetVersion time: " + sw.ElapsedMilliseconds); } GUILayout.EndHorizontal(); } NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUILayout.Label("选择拷贝资源:", GUILayout.Width(120f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (m_copyResourcesInfoList != null) foreach (var item in m_copyResourcesInfoList) { item.check = GUILayout.Toggle(item.check, item.sourcePath); if (item.check && GUILayout.Button("导出", GUILayout.Width(120f))) { //var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion); var targetPath = m_newVersionFolder + ExportFilesPath; ExportScenesManager.CopyFolder(Path.Combine(targetPath, item.targetPath), Application.dataPath + item.sourcePath, item.extention); } } GUILayout.EndHorizontal(); NGUIEditorTools.DrawSeparator(); GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); if (GUILayout.Button("MogoLib", GUILayout.Width(120f))) { ExportMogoLib(); } if (GUILayout.Button("压缩", GUILayout.Width(120f))) { Zip(); } if (GUILayout.Button("完整打包", GUILayout.Width(120f))) { var sw = new Stopwatch(); sw.Start(); var targetPath = m_newVersionFolder + ExportFilesPath; foreach (var item in m_buildResourcesInfoList) { if (item.check) BuildAssetBundleMainAsset(item, targetPath); } foreach (var item in m_copyResourcesInfoList) { if (item.check) { ExportScenesManager.CopyFolder(Path.Combine(targetPath, item.targetPath), Application.dataPath + item.sourcePath, item.extention); } } sw.Stop(); LoggerHelper.Debug("完整打包 time: " + sw.ElapsedMilliseconds); } if (GUILayout.Button("生成资源版本", GUILayout.Width(120f))) { var root = Application.dataPath; var dataPath = new DirectoryInfo(Application.dataPath).Parent.FullName.Replace("\\", "/") + "/"; System.Action action = () => { BuildAssetVersion(root, dataPath, m_newVersion, m_newVersionFolder); }; action.BeginInvoke(null, null); } if (GUILayout.Button("比对资源版本", GUILayout.Width(120f))) { var currentVersionFolder = GetVersionFolder(m_currentVersion); var diff = FindVersionDiff(currentVersionFolder, m_newVersionFolder, "version"); LogDebug(diff.PackArray('\n')); diff = BundleExporter.FindDependencyRoot(diff); LogDebug("Root resource:\n" + diff.PackArray('\n')); var targetPath = m_newVersionFolder + ExportFilesPath; BundleExporter.BuildBundleWithRoot(diff, targetPath); } if (GUILayout.Button("清理MR", GUILayout.Width(120f))) { if (!EditorUtility.DisplayDialog("Conform", "确认清理?", "yes", "no")) return; var rootPath = ExportScenesManager.GetFolderPath(ExportScenesManager.SubMogoResources); Directory.Delete(rootPath, true); LogDebug("clean success."); } if (GUILayout.Button("拷贝MR", GUILayout.Width(120f))) { var targetPath = ExportScenesManager.GetFolderPath(ExportScenesManager.SubMogoResources); var sourcePath = m_newVersionFolder + ExportFilesPath; ExportScenesManager.DirectoryCopy(sourcePath, targetPath, true); LogDebug("copy success."); } GUILayout.EndHorizontal(); }
//获得被拷贝出去的临时项目路径export下的最新导出版本,比如client_Temp1/Export/0.0.0.3 public static string GetNewVersionByTempClientPath(string path) { var dirs = Directory.GetDirectories(path); var currentVersion = new VersionCodeInfo("0.0.0.1"); foreach (var item in dirs) { var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name); if (fileVersion.Compare(currentVersion) > 0) currentVersion = fileVersion; } return currentVersion.ToString(); }
public void PackManually(string typeName, VersionCodeInfo newVersion) { var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString()); var resourceFolder = Path.Combine(versionFolder, typeName); var folder = Path.Combine(resourceFolder, ExportScenesManager.SubMogoResources);//获取输出目录 var folders = new DirectoryInfo(folder).GetDirectories().OrderBy(t => t.CreationTime); PackManually(folders.ToList(), typeName, newVersion); //ExportScenesManager.PackUpdatedFiles(targetPath, exported, typeName, typeName);//打包更新的文件。 }
public VersionManagerInfo() { ProgramVersionInfo = new VersionCodeInfo("0.0.0.1"); ResouceVersionInfo = new VersionCodeInfo("0.0.0.0"); PackageList = String.Empty; PackageUrl = String.Empty; ApkUrl = String.Empty; }
private void BuildResourceInfoManually(VersionCodeInfo currentVersion, VersionCodeInfo newVersion, string typeName, string resFolder, List<string> targets, bool isPopInBuild = false, params string[] extentions) { //LoadVersion(currentVersion.ToString()); //var newVersion = currentVersion.GetUpperVersion(); var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString()); var targetFolder = Path.Combine(versionFolder, typeName); var folder = Path.Combine(targetFolder, ExportScenesManager.SubMogoResources);//获取输出目录 Stopwatch sw = new Stopwatch(); sw.Start(); //Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);//Selection.objects; var expordedFiles = new List<string>(); foreach (var item in targets) { var path = "Assets" + item.ReplaceFirst(Application.dataPath, ""); LogDebug(path); var o = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object)); //LogDebug(o); var target = folder + "/" + Path.GetFileNameWithoutExtension(item); expordedFiles.AddRange(ExportScenesManager.ExportResourcesInfo(new UnityEngine.Object[] { o }, newVersion.ToString(), target, resFolder, isPopInBuild, extentions));//导出资源,并将重新输出的资源返回并记录 //AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } LogDebug("m_fileVersions.Count" + m_fileVersions.Count); //ExportScenesManager.SaveExportedFileList(expordedFiles, ExportScenesManager.SubExportedFileList, targetFolder, targetFolder);//记录此次导出的文件信息。 //LogError("SaveExportedFileList time: " + sw.ElapsedMilliseconds); //var uFiles = FindUpdatedFiles(folder);//获取有更新的资源。 //var updatedFiles = uFiles.Keys.ToList(); //LogError("FindUpdatedFiles time: " + sw.ElapsedMilliseconds); //LogError("PackUpdatedFiles time: " + sw.ElapsedMilliseconds); //LogError("Total time: " + sw.ElapsedMilliseconds); sw.Stop(); //SaveVersion(newVersion.ToString()); }
public static VersionCodeInfo GetNewVersionCode() { var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath)); var currentVersion = new VersionCodeInfo("0.0.0.1"); foreach (var item in dirs) { var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name); if (fileVersion.Compare(currentVersion) > 0) currentVersion = fileVersion; } return currentVersion; }
/// <summary> /// 比较版本号,自己比参数大,返回1,比参数小,返回-1,相等返回0。 /// </summary> /// <param name="info">比较版本号。</param> /// <returns>自己比参数大,返回1,比参数小,返回-1,相等返回0。</returns> public int Compare(VersionCodeInfo info) { var count = this.m_tags.Count < info.m_tags.Count ? this.m_tags.Count : info.m_tags.Count; for (int i = 0; i < count; i++) { if (this.m_tags[i] == info.m_tags[i]) continue; else return this.m_tags[i] > info.m_tags[i] ? 1 : -1; } return 0; }
public void PackManually(List<DirectoryInfo> folders, string typeName, VersionCodeInfo newVersion) { var versionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), newVersion.ToString()); var resourceFolder = Path.Combine(versionFolder, typeName); var targetPath = resourceFolder + "/target"; var exported = new List<string>(); foreach (var folderPath in folders) { LogDebug("folderPath: " + folderPath); var files = Directory.GetFiles(folderPath.FullName, "*.*", SearchOption.AllDirectories); foreach (var file in files) { var subPath = file.ReplaceFirst(folderPath.FullName, ""); var target = targetPath + subPath; if (!File.Exists(target)) { //LogDebug("target: " + target); if (!Directory.Exists(Utils.GetDirectoryName(target.Replace("\\", "/")))) Directory.CreateDirectory(Utils.GetDirectoryName(target.Replace("\\", "/"))); File.Copy(file, target); exported.Add(target); } //else // LogDebug("Same File: " + subPath); } } LogDebug("copy files: " + exported.Count); }
public static void ExportBundlesEx() { ExportScenesManager.AutoSwitchTarget(); var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath)); //if (files.Length != 0) //{ var currentVersion = new VersionCodeInfo("0.0.0.1"); foreach (var item in dirs) { var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name); if (fileVersion.Compare(currentVersion) > 0) currentVersion = fileVersion; } //var m_currentVersion = currentVersion.GetLowerVersion(); var m_newVersion = currentVersion.ToString(); var m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/"); var targetPath = m_newVersionFolder + BuildProjectExWizard.ExportFilesPath; var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); var paths = (from s in selection let path = AssetDatabase.GetAssetPath(s) where File.Exists(path) select path).ToArray(); foreach (string item in paths) { Debug.Log("ex "+item); ExportBundle(new string[] { item }, targetPath); } }