From 96079d4906ef852366c35c1f72e0f4d83ea4965f Mon Sep 17 00:00:00 2001 From: Razmoth <32140579+Razmoth@users.noreply.github.com> Date: Sun, 17 Sep 2023 14:49:12 +0400 Subject: [PATCH] - [GUI] fix bug when building `CABMap` with stripped version. - [CLI] add option to set unity version when stripped. --- AssetStudioCLI/Components/CommandLine.cs | 5 +++++ AssetStudioCLI/Program.cs | 3 +++ AssetStudioGUI/AssetStudioGUIForm.cs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/AssetStudioCLI/Components/CommandLine.cs b/AssetStudioCLI/Components/CommandLine.cs index acee451..00df181 100644 --- a/AssetStudioCLI/Components/CommandLine.cs +++ b/AssetStudioCLI/Components/CommandLine.cs @@ -31,6 +31,7 @@ namespace AssetStudioCLI optionsBinder.MapOp, optionsBinder.MapType, optionsBinder.MapName, + optionsBinder.UnityVersion, optionsBinder.GroupAssetsType, optionsBinder.Model, optionsBinder.Key, @@ -57,6 +58,7 @@ namespace AssetStudioCLI public MapOpType MapOp { get; set; } public ExportListType MapType { get; set; } public string MapName { get; set; } + public string UnityVersion { get; set; } public AssetGroupOption GroupAssetsType { get; set; } public bool Model { get; set; } public byte Key { get; set; } @@ -78,6 +80,7 @@ namespace AssetStudioCLI public readonly Option MapOp; public readonly Option MapType; public readonly Option MapName; + public readonly Option UnityVersion; public readonly Option GroupAssetsType; public readonly Option Model; public readonly Option Key; @@ -99,6 +102,7 @@ namespace AssetStudioCLI MapOp = new Option("--map_op", "Specify which map to build."); MapType = new Option("--map_type", "AssetMap output type."); MapName = new Option("--map_name", () => "assets_map", "Specify AssetMap file name."); + UnityVersion = new Option("--version", "Specify Unity version."); GroupAssetsType = new Option("--group_assets", "Specify how exported assets should be grouped."); Model = new Option("--models", "Enable to export models only"); AIFile = new Option("--ai_file", "Specify asset_index json file path (to recover GI containers).").LegalFilePathsOnly(); @@ -188,6 +192,7 @@ namespace AssetStudioCLI MapOp = bindingContext.ParseResult.GetValueForOption(MapOp), MapType = bindingContext.ParseResult.GetValueForOption(MapType), MapName = bindingContext.ParseResult.GetValueForOption(MapName), + UnityVersion = bindingContext.ParseResult.GetValueForOption(UnityVersion), GroupAssetsType = bindingContext.ParseResult.GetValueForOption(GroupAssetsType), Model = bindingContext.ParseResult.GetValueForOption(Model), Key = bindingContext.ParseResult.GetValueForOption(Key), diff --git a/AssetStudioCLI/Program.cs b/AssetStudioCLI/Program.cs index 97993fb..4849a1f 100644 --- a/AssetStudioCLI/Program.cs +++ b/AssetStudioCLI/Program.cs @@ -47,8 +47,11 @@ namespace AssetStudioCLI Shader.Parsable = !Settings.Default.disableShader; Renderer.Parsable = !Settings.Default.disableRenderer; AnimationClip.Parsable = !Settings.Default.disableAnimationClip; + AssetsHelper.SetUnityVersion(o.UnityVersion); + assetsManager.Silent = o.Silent; assetsManager.Game = game; + assetsManager.SpecifyUnityVersion = o.UnityVersion; ModelOnly = o.Model; o.Output.Create(); diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index b4e5cd4..5757375 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -2110,6 +2110,7 @@ namespace AssetStudioGUI } } + var version = assetsManager.SpecifyUnityVersion; var openFolderDialog = new OpenFolderDialog(); openFolderDialog.Title = "Select Game Folder"; if (openFolderDialog.ShowDialog(this) == DialogResult.OK) @@ -2117,6 +2118,7 @@ namespace AssetStudioGUI Logger.Info("Scanning for files..."); var files = Directory.GetFiles(openFolderDialog.Folder, "*.*", SearchOption.AllDirectories).ToArray(); Logger.Info($"Found {files.Length} files"); + AssetsHelper.SetUnityVersion(version); await Task.Run(() => AssetsHelper.BuildCABMap(files, name, openFolderDialog.Folder, Studio.Game)); } InvokeUpdate(miscToolStripMenuItem, true); @@ -2164,6 +2166,7 @@ namespace AssetStudioGUI } } + var version = assetsManager.SpecifyUnityVersion; var openFolderDialog = new OpenFolderDialog(); openFolderDialog.Title = "Select Game Folder"; if (openFolderDialog.ShowDialog(this) == DialogResult.OK) @@ -2187,6 +2190,7 @@ namespace AssetStudioGUI } } saveDirectoryBackup = saveFolderDialog.Folder; + AssetsHelper.SetUnityVersion(version); await Task.Run(() => AssetsHelper.BuildBoth(files, name, openFolderDialog.Folder, Studio.Game, saveFolderDialog.Folder, exportListType)); } }