Add option to disable asset loading via typetree

This commit is contained in:
VaDiM 2024-03-13 22:28:16 +03:00
parent 3effd06e64
commit 3f004f74d1
5 changed files with 67 additions and 34 deletions

View File

@ -12,6 +12,7 @@ namespace AssetStudio
{ {
public string SpecifyUnityVersion; public string SpecifyUnityVersion;
public bool ZstdEnabled = true; public bool ZstdEnabled = true;
public bool LoadingViaTypeTreeEnabled = true;
public List<SerializedFile> assetsFileList = new List<SerializedFile>(); public List<SerializedFile> assetsFileList = new List<SerializedFile>();
private HashSet<ClassIDType> filteredAssetTypesList = new HashSet<ClassIDType>(); private HashSet<ClassIDType> filteredAssetTypesList = new HashSet<ClassIDType>();
@ -502,9 +503,9 @@ namespace AssetStudio
obj = new Animation(objectReader); obj = new Animation(objectReader);
break; break;
case ClassIDType.AnimationClip: case ClassIDType.AnimationClip:
obj = objectReader.serializedType?.m_Type == null obj = objectReader.serializedType?.m_Type != null && LoadingViaTypeTreeEnabled
? new AnimationClip(objectReader) ? new AnimationClip(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader))
: new AnimationClip(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader)); : new AnimationClip(objectReader);
break; break;
case ClassIDType.Animator: case ClassIDType.Animator:
obj = new Animator(objectReader); obj = new Animator(objectReader);
@ -577,14 +578,14 @@ namespace AssetStudio
obj = new TextAsset(objectReader); obj = new TextAsset(objectReader);
break; break;
case ClassIDType.Texture2D: case ClassIDType.Texture2D:
obj = objectReader.serializedType?.m_Type == null obj = objectReader.serializedType?.m_Type != null && LoadingViaTypeTreeEnabled
? new Texture2D(objectReader) ? new Texture2D(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader))
: new Texture2D(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader)); : new Texture2D(objectReader);
break; break;
case ClassIDType.Texture2DArray: case ClassIDType.Texture2DArray:
obj = objectReader.serializedType?.m_Type == null obj = objectReader.serializedType?.m_Type != null && LoadingViaTypeTreeEnabled
? new Texture2DArray(objectReader) ? new Texture2DArray(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader))
: new Texture2DArray(objectReader, TypeTreeHelper.ReadType(objectReader.serializedType.m_Type, objectReader)); : new Texture2DArray(objectReader);
break; break;
case ClassIDType.Transform: case ClassIDType.Transform:
obj = new Transform(objectReader); obj = new Transform(objectReader);

View File

@ -116,6 +116,7 @@ namespace AssetStudioCLI.Options
public static Option<string> o_assemblyPath; public static Option<string> o_assemblyPath;
public static Option<string> o_unityVersion; public static Option<string> o_unityVersion;
public static Option<bool> f_notRestoreExtensionName; public static Option<bool> f_notRestoreExtensionName;
public static Option<bool> f_avoidLoadingViaTypetree;
public static Option<bool> f_loadAllAssets; public static Option<bool> f_loadAllAssets;
static CLIOptions() static CLIOptions()
@ -431,6 +432,15 @@ namespace AssetStudioCLI.Options
optionHelpGroup: HelpGroups.Advanced, optionHelpGroup: HelpGroups.Advanced,
isFlag: true isFlag: true
); );
f_avoidLoadingViaTypetree = new GroupedOption<bool>
(
optionDefaultValue: false,
optionName: "--avoid-typetree-loading",
optionDescription: "(Flag) If specified, AssetStudio will not try to load assets using their type tree\n",
optionExample: "",
optionHelpGroup: HelpGroups.Advanced,
isFlag: true
);
f_loadAllAssets = new GroupedOption<bool> f_loadAllAssets = new GroupedOption<bool>
( (
optionDefaultValue: false, optionDefaultValue: false,
@ -553,10 +563,24 @@ namespace AssetStudioCLI.Options
switch(flag) switch(flag)
{ {
case "--l2d-force-bezier":
if (o_workMode.Value != WorkMode.ExportLive2D)
{
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
ShowOptionDescription(o_workMode);
return;
}
f_l2dForceBezier.Value = true;
resplittedArgs.RemoveAt(i);
break;
case "--not-restore-extension": case "--not-restore-extension":
f_notRestoreExtensionName.Value = true; f_notRestoreExtensionName.Value = true;
resplittedArgs.RemoveAt(i); resplittedArgs.RemoveAt(i);
break; break;
case "--avoid-typetree-loading":
f_avoidLoadingViaTypetree.Value = true;
resplittedArgs.RemoveAt(i);
break;
case "--load-all": case "--load-all":
switch (o_workMode.Value) switch (o_workMode.Value)
{ {
@ -572,16 +596,6 @@ namespace AssetStudioCLI.Options
return; return;
} }
break; break;
case "--l2d-force-bezier":
if (o_workMode.Value != WorkMode.ExportLive2D)
{
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
ShowOptionDescription(o_workMode);
return;
}
f_l2dForceBezier.Value = true;
resplittedArgs.RemoveAt(i);
break;
} }
} }
#endregion #endregion
@ -1083,6 +1097,7 @@ namespace AssetStudioCLI.Options
{ {
sb.AppendLine($"# Custom Compression Type: {o_customCompressionType}"); sb.AppendLine($"# Custom Compression Type: {o_customCompressionType}");
} }
sb.AppendLine($"# Load Assets via Typetree: {!f_avoidLoadingViaTypetree.Value}");
sb.AppendLine($"# Input Path: \"{inputPath}\""); sb.AppendLine($"# Input Path: \"{inputPath}\"");
switch (o_workMode.Value) switch (o_workMode.Value)
{ {

View File

@ -35,6 +35,7 @@ namespace AssetStudioCLI
var isLoaded = false; var isLoaded = false;
assetsManager.SpecifyUnityVersion = CLIOptions.o_unityVersion.Value; assetsManager.SpecifyUnityVersion = CLIOptions.o_unityVersion.Value;
assetsManager.ZstdEnabled = CLIOptions.o_customCompressionType.Value == CustomCompressionType.Zstd; assetsManager.ZstdEnabled = CLIOptions.o_customCompressionType.Value == CustomCompressionType.Zstd;
assetsManager.LoadingViaTypeTreeEnabled = !CLIOptions.f_avoidLoadingViaTypetree.Value;
if (!CLIOptions.f_loadAllAssets.Value) if (!CLIOptions.f_loadAllAssets.Value)
{ {
assetsManager.SetAssetFilter(CLIOptions.o_exportAssetTypes.Value); assetsManager.SetAssetFilter(CLIOptions.o_exportAssetTypes.Value);

View File

@ -88,11 +88,13 @@
this.showConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem15 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem15 = new System.Windows.Forms.ToolStripMenuItem();
this.writeLogToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.writeLogToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.disableAssetLoadingViaTypetreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportClassStructuresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.sceneTreeView = new AssetStudioGUI.GOHierarchy();
this.treeSearch = new System.Windows.Forms.TextBox(); this.treeSearch = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.assetListView = new System.Windows.Forms.ListView(); this.assetListView = new System.Windows.Forms.ListView();
@ -155,7 +157,6 @@
this.exportL2DWithClipsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportL2DWithClipsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.goToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sceneTreeView = new AssetStudioGUI.GOHierarchy();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
@ -314,7 +315,7 @@
this.customCompressionZstdToolStripMenuItem.CheckOnClick = true; this.customCompressionZstdToolStripMenuItem.CheckOnClick = true;
this.customCompressionZstdToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.customCompressionZstdToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.customCompressionZstdToolStripMenuItem.Name = "customCompressionZstdToolStripMenuItem"; this.customCompressionZstdToolStripMenuItem.Name = "customCompressionZstdToolStripMenuItem";
this.customCompressionZstdToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.customCompressionZstdToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.customCompressionZstdToolStripMenuItem.Text = "Zstd"; this.customCompressionZstdToolStripMenuItem.Text = "Zstd";
this.customCompressionZstdToolStripMenuItem.ToolTipText = "If selected, Zstd-decompression will be used for assets with custom compression t" + this.customCompressionZstdToolStripMenuItem.ToolTipText = "If selected, Zstd-decompression will be used for assets with custom compression t" +
"ype"; "ype";
@ -324,7 +325,7 @@
// //
this.customCompressionLZ4ToolStripMenuItem.CheckOnClick = true; this.customCompressionLZ4ToolStripMenuItem.CheckOnClick = true;
this.customCompressionLZ4ToolStripMenuItem.Name = "customCompressionLZ4ToolStripMenuItem"; this.customCompressionLZ4ToolStripMenuItem.Name = "customCompressionLZ4ToolStripMenuItem";
this.customCompressionLZ4ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.customCompressionLZ4ToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.customCompressionLZ4ToolStripMenuItem.Text = "Lz4/Lz4HC"; this.customCompressionLZ4ToolStripMenuItem.Text = "Lz4/Lz4HC";
this.customCompressionLZ4ToolStripMenuItem.ToolTipText = "If selected, Lz4-decompression will be used for assets with custom compression ty" + this.customCompressionLZ4ToolStripMenuItem.ToolTipText = "If selected, Lz4-decompression will be used for assets with custom compression ty" +
"pe"; "pe";
@ -637,6 +638,7 @@
this.showConsoleToolStripMenuItem, this.showConsoleToolStripMenuItem,
this.toolStripMenuItem15, this.toolStripMenuItem15,
this.writeLogToFileToolStripMenuItem, this.writeLogToFileToolStripMenuItem,
this.disableAssetLoadingViaTypetreeToolStripMenuItem,
this.exportClassStructuresMenuItem}); this.exportClassStructuresMenuItem});
this.debugMenuItem.Name = "debugMenuItem"; this.debugMenuItem.Name = "debugMenuItem";
this.debugMenuItem.Size = new System.Drawing.Size(54, 20); this.debugMenuItem.Size = new System.Drawing.Size(54, 20);
@ -668,6 +670,14 @@
this.writeLogToFileToolStripMenuItem.Text = "Write log to file"; this.writeLogToFileToolStripMenuItem.Text = "Write log to file";
this.writeLogToFileToolStripMenuItem.CheckedChanged += new System.EventHandler(this.writeLogToFileToolStripMenuItem_CheckedChanged); this.writeLogToFileToolStripMenuItem.CheckedChanged += new System.EventHandler(this.writeLogToFileToolStripMenuItem_CheckedChanged);
// //
// disableAssetLoadingViaTypetreeToolStripMenuItem
//
this.disableAssetLoadingViaTypetreeToolStripMenuItem.CheckOnClick = true;
this.disableAssetLoadingViaTypetreeToolStripMenuItem.Name = "disableAssetLoadingViaTypetreeToolStripMenuItem";
this.disableAssetLoadingViaTypetreeToolStripMenuItem.Size = new System.Drawing.Size(288, 22);
this.disableAssetLoadingViaTypetreeToolStripMenuItem.Text = "Disable asset loading via typetree";
this.disableAssetLoadingViaTypetreeToolStripMenuItem.Click += new System.EventHandler(this.disableAssetLoadingViaTypetreeToolStripMenuItem_Click);
//
// exportClassStructuresMenuItem // exportClassStructuresMenuItem
// //
this.exportClassStructuresMenuItem.Name = "exportClassStructuresMenuItem"; this.exportClassStructuresMenuItem.Name = "exportClassStructuresMenuItem";
@ -731,6 +741,18 @@
this.tabPage1.Text = "Scene Hierarchy"; this.tabPage1.Text = "Scene Hierarchy";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// sceneTreeView
//
this.sceneTreeView.CheckBoxes = true;
this.sceneTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.sceneTreeView.HideSelection = false;
this.sceneTreeView.Location = new System.Drawing.Point(0, 20);
this.sceneTreeView.Name = "sceneTreeView";
this.sceneTreeView.Size = new System.Drawing.Size(472, 587);
this.sceneTreeView.TabIndex = 1;
this.sceneTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.sceneTreeView_AfterCheck);
this.sceneTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.sceneTreeView_NodeMouseClick);
//
// treeSearch // treeSearch
// //
this.treeSearch.Dock = System.Windows.Forms.DockStyle.Top; this.treeSearch.Dock = System.Windows.Forms.DockStyle.Top;
@ -1386,18 +1408,6 @@
this.showOriginalFileToolStripMenuItem.Visible = false; this.showOriginalFileToolStripMenuItem.Visible = false;
this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click); this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click);
// //
// sceneTreeView
//
this.sceneTreeView.CheckBoxes = true;
this.sceneTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.sceneTreeView.HideSelection = false;
this.sceneTreeView.Location = new System.Drawing.Point(0, 20);
this.sceneTreeView.Name = "sceneTreeView";
this.sceneTreeView.Size = new System.Drawing.Size(472, 587);
this.sceneTreeView.TabIndex = 1;
this.sceneTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.sceneTreeView_AfterCheck);
this.sceneTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.sceneTreeView_NodeMouseClick);
//
// AssetStudioGUIForm // AssetStudioGUIForm
// //
this.AllowDrop = true; this.AllowDrop = true;
@ -1576,6 +1586,7 @@
private System.Windows.Forms.ToolStripMenuItem customCompressionTypeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem customCompressionTypeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem customCompressionZstdToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem customCompressionZstdToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem customCompressionLZ4ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem customCompressionLZ4ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem disableAssetLoadingViaTypetreeToolStripMenuItem;
} }
} }

View File

@ -2281,6 +2281,11 @@ namespace AssetStudioGUI
assetsManager.ZstdEnabled = customCompressionZstdToolStripMenuItem.Checked; assetsManager.ZstdEnabled = customCompressionZstdToolStripMenuItem.Checked;
} }
private void disableAssetLoadingViaTypetreeToolStripMenuItem_Click(object sender, EventArgs e)
{
assetsManager.LoadingViaTypeTreeEnabled = !disableAssetLoadingViaTypetreeToolStripMenuItem.Checked;
}
#region FMOD #region FMOD
private void FMODinit() private void FMODinit()
{ {