Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [GUI] fix bug when building CABMap with stripped version.
Browse files Browse the repository at this point in the history
- [CLI] add option to set unity version when stripped.
  • Loading branch information
Razmoth committed Sep 17, 2023
1 parent 31734c2 commit 96079d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions AssetStudioCLI/Components/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static RootCommand RegisterOptions()
optionsBinder.MapOp,
optionsBinder.MapType,
optionsBinder.MapName,
optionsBinder.UnityVersion,
optionsBinder.GroupAssetsType,
optionsBinder.Model,
optionsBinder.Key,
Expand All @@ -57,6 +58,7 @@ public class Options
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; }
Expand All @@ -78,6 +80,7 @@ public class OptionsBinder : BinderBase<Options>
public readonly Option<MapOpType> MapOp;
public readonly Option<ExportListType> MapType;
public readonly Option<string> MapName;
public readonly Option<string> UnityVersion;
public readonly Option<AssetGroupOption> GroupAssetsType;
public readonly Option<bool> Model;
public readonly Option<byte> Key;
Expand All @@ -99,6 +102,7 @@ public OptionsBinder()
MapOp = new Option<MapOpType>("--map_op", "Specify which map to build.");
MapType = new Option<ExportListType>("--map_type", "AssetMap output type.");
MapName = new Option<string>("--map_name", () => "assets_map", "Specify AssetMap file name.");
UnityVersion = new Option<string>("--version", "Specify Unity version.");
GroupAssetsType = new Option<AssetGroupOption>("--group_assets", "Specify how exported assets should be grouped.");
Model = new Option<bool>("--models", "Enable to export models only");
AIFile = new Option<FileInfo>("--ai_file", "Specify asset_index json file path (to recover GI containers).").LegalFilePathsOnly();
Expand Down Expand Up @@ -188,6 +192,7 @@ protected override Options GetBoundValue(BindingContext bindingContext) =>
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),
Expand Down
3 changes: 3 additions & 0 deletions AssetStudioCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ public static void Run(Options o)
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();

Expand Down
4 changes: 4 additions & 0 deletions AssetStudioGUI/AssetStudioGUIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,13 +2110,15 @@ private async void buildMapToolStripMenuItem_Click(object sender, EventArgs e)
}
}

var version = assetsManager.SpecifyUnityVersion;
var openFolderDialog = new OpenFolderDialog();
openFolderDialog.Title = "Select Game Folder";
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
{
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);
Expand Down Expand Up @@ -2164,6 +2166,7 @@ private async void buildBothToolStripMenuItem_Click(object sender, EventArgs e)
}
}

var version = assetsManager.SpecifyUnityVersion;
var openFolderDialog = new OpenFolderDialog();
openFolderDialog.Title = "Select Game Folder";
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
Expand All @@ -2187,6 +2190,7 @@ private async void buildBothToolStripMenuItem_Click(object sender, EventArgs e)
}
}
saveDirectoryBackup = saveFolderDialog.Folder;
AssetsHelper.SetUnityVersion(version);
await Task.Run(() => AssetsHelper.BuildBoth(files, name, openFolderDialog.Folder, Studio.Game, saveFolderDialog.Folder, exportListType));
}
}
Expand Down

0 comments on commit 96079d4

Please sign in to comment.