Add option to extract raw byte array from MonoBehaviour assets

This commit is contained in:
VaDiM
2025-10-07 01:07:48 +03:00
parent 6d5b633d55
commit d1bf0c5a37
7 changed files with 111 additions and 8 deletions

View File

@ -32,6 +32,7 @@
this.OKbutton = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.rawByteArrayFromMono = new System.Windows.Forms.CheckBox();
this.overwriteExistingFiles = new System.Windows.Forms.CheckBox();
this.parallelExportMaxLabel = new System.Windows.Forms.Label();
this.parallelExportCheckBox = new System.Windows.Forms.CheckBox();
@ -97,7 +98,7 @@
// OKbutton
//
this.OKbutton.BackColor = System.Drawing.SystemColors.ButtonFace;
this.OKbutton.Location = new System.Drawing.Point(460, 448);
this.OKbutton.Location = new System.Drawing.Point(460, 459);
this.OKbutton.Name = "OKbutton";
this.OKbutton.Size = new System.Drawing.Size(75, 23);
this.OKbutton.TabIndex = 4;
@ -109,7 +110,7 @@
//
this.Cancel.BackColor = System.Drawing.SystemColors.ButtonFace;
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(541, 448);
this.Cancel.Location = new System.Drawing.Point(541, 459);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 5;
@ -121,6 +122,7 @@
//
this.groupBox1.AutoSize = true;
this.groupBox1.BackColor = System.Drawing.SystemColors.Menu;
this.groupBox1.Controls.Add(this.rawByteArrayFromMono);
this.groupBox1.Controls.Add(this.overwriteExistingFiles);
this.groupBox1.Controls.Add(this.parallelExportMaxLabel);
this.groupBox1.Controls.Add(this.parallelExportCheckBox);
@ -137,11 +139,21 @@
this.groupBox1.Controls.Add(this.converttexture);
this.groupBox1.Location = new System.Drawing.Point(12, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(316, 280);
this.groupBox1.Size = new System.Drawing.Size(316, 303);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Export";
//
// rawByteArrayFromMono
//
this.rawByteArrayFromMono.AutoSize = true;
this.rawByteArrayFromMono.Location = new System.Drawing.Point(6, 267);
this.rawByteArrayFromMono.Name = "rawByteArrayFromMono";
this.rawByteArrayFromMono.Size = new System.Drawing.Size(290, 17);
this.rawByteArrayFromMono.TabIndex = 15;
this.rawByteArrayFromMono.Text = "Raw: Extract raw byte array from MonoBehaviour assets";
this.rawByteArrayFromMono.UseVisualStyleBackColor = true;
//
// overwriteExistingFiles
//
this.overwriteExistingFiles.AutoSize = true;
@ -380,7 +392,7 @@
this.l2dGroupBox.Controls.Add(this.l2dMotionExportMethodPanel);
this.l2dGroupBox.Controls.Add(this.l2dMotionExportMethodLabel);
this.l2dGroupBox.Controls.Add(this.l2dForceBezierCheckBox);
this.l2dGroupBox.Location = new System.Drawing.Point(12, 291);
this.l2dGroupBox.Location = new System.Drawing.Point(12, 304);
this.l2dGroupBox.Name = "l2dGroupBox";
this.l2dGroupBox.Size = new System.Drawing.Size(316, 149);
this.l2dGroupBox.TabIndex = 2;
@ -502,7 +514,7 @@
this.groupBox2.Controls.Add(this.eulerFilter);
this.groupBox2.Location = new System.Drawing.Point(328, 13);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(289, 427);
this.groupBox2.Size = new System.Drawing.Size(289, 440);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Fbx";
@ -510,7 +522,7 @@
// fbxResetButton
//
this.fbxResetButton.BackColor = System.Drawing.SystemColors.ButtonFace;
this.fbxResetButton.Location = new System.Drawing.Point(208, 384);
this.fbxResetButton.Location = new System.Drawing.Point(208, 398);
this.fbxResetButton.Name = "fbxResetButton";
this.fbxResetButton.Size = new System.Drawing.Size(75, 23);
this.fbxResetButton.TabIndex = 21;
@ -782,7 +794,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Menu;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(628, 483);
this.ClientSize = new System.Drawing.Size(628, 494);
this.Controls.Add(this.l2dGroupBox);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
@ -869,5 +881,6 @@
private System.Windows.Forms.Label uvBindingsLabel;
private System.Windows.Forms.Button fbxResetButton;
private System.Windows.Forms.CheckBox overwriteExistingFiles;
private System.Windows.Forms.CheckBox rawByteArrayFromMono;
}
}

View File

@ -29,7 +29,8 @@ namespace AssetStudioGUI
parallelExportUpDown.Value = taskCount <= 0 ? maxParallelTasks : Math.Min(taskCount, maxParallelTasks);
parallelExportMaxLabel.Text += maxParallelTasks;
parallelExportCheckBox.Checked = Properties.Settings.Default.parallelExport;
rawByteArrayFromMono.Checked = Properties.Settings.Default.rawByteArrayFromMono;
l2dModelGroupComboBox.SelectedIndex = (int)Properties.Settings.Default.l2dModelGroupOption;
l2dAssetSearchByFilenameCheckBox.Checked = Properties.Settings.Default.l2dAssetSearchByFilename;
var defaultMotionMode = Properties.Settings.Default.l2dMotionMode.ToString();
@ -53,6 +54,7 @@ namespace AssetStudioGUI
Properties.Settings.Default.openAfterExport = openAfterExport.Checked;
Properties.Settings.Default.parallelExport = parallelExportCheckBox.Checked;
Properties.Settings.Default.parallelExportCount = (int)parallelExportUpDown.Value;
Properties.Settings.Default.rawByteArrayFromMono = rawByteArrayFromMono.Checked;
Properties.Settings.Default.l2dModelGroupOption = (CubismLive2DExtractor.Live2DModelGroupOption)l2dModelGroupComboBox.SelectedIndex;
Properties.Settings.Default.l2dAssetSearchByFilename = l2dAssetSearchByFilenameCheckBox.Checked;

View File

@ -276,6 +276,30 @@ namespace AssetStudioGUI
m_VideoClip.m_VideoData.WriteData(exportFullPath.Replace(".dat", "_data.dat"));
}
break;
case MonoBehaviour m_MonoBehaviour when Properties.Settings.Default.rawByteArrayFromMono:
var reader = m_MonoBehaviour.reader;
reader.Reset();
var assetData = reader.ReadBytes(28); //PPtr<GameObject> m_GameObject, m_Enabled, PPtr<MonoScript>
var assetNameLen = reader.ReadInt32();
reader.Position -= 4;
var assetNameBytes = reader.ReadBytes(assetNameLen + 4);
if (assetNameLen > 0)
reader.AlignStream();
var arrayLen = reader.ReadInt32();
if (arrayLen <= 0 || arrayLen > reader.Remaining)
break;
using (var outStream = new FileStream(exportFullPath.Replace(".dat", "_extracted.dat"), FileMode.Create))
{
reader.BaseStream.CopyTo(outStream, size: arrayLen);
}
using (var outStream = new FileStream(exportFullPath, FileMode.Create))
{
outStream.Write(assetData, 0, assetData.Length);
outStream.Write(assetNameBytes, 0, assetNameBytes.Length);
if (reader.Remaining > 0)
reader.BaseStream.CopyTo(outStream, size: reader.Remaining);
}
return true;
}
File.WriteAllBytes(exportFullPath, item.Asset.GetRawData());
return true;

View File

@ -358,5 +358,17 @@ namespace AssetStudioGUI.Properties {
this["meshLazyLoad"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool rawByteArrayFromMono {
get {
return ((bool)(this["rawByteArrayFromMono"]));
}
set {
this["rawByteArrayFromMono"] = value;
}
}
}
}

View File

@ -86,5 +86,8 @@
<Setting Name="meshLazyLoad" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="rawByteArrayFromMono" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>