mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
added option to support version stripped files, close #766
This commit is contained in:
parent
973a1076e4
commit
c1cddce031
@ -9,6 +9,7 @@ namespace AssetStudio
|
||||
{
|
||||
public class AssetsManager
|
||||
{
|
||||
public string SpecifyUnityVersion;
|
||||
public List<SerializedFile> assetsFileList = new List<SerializedFile>();
|
||||
internal Dictionary<string, int> assetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
internal Dictionary<string, BinaryReader> resourceFileReaders = new Dictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
||||
@ -82,6 +83,7 @@ namespace AssetStudio
|
||||
try
|
||||
{
|
||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
||||
CheckStrippedVersion(assetsFile);
|
||||
assetsFileList.Add(assetsFile);
|
||||
assetsFileListHash.Add(assetsFile.fileName);
|
||||
|
||||
@ -130,10 +132,11 @@ namespace AssetStudio
|
||||
{
|
||||
var assetsFile = new SerializedFile(this, fullName, reader);
|
||||
assetsFile.originalPath = originalPath;
|
||||
if (assetsFile.header.m_Version < SerializedFileFormatVersion.kUnknown_7)
|
||||
if (!string.IsNullOrEmpty(unityVersion) && assetsFile.header.m_Version < SerializedFileFormatVersion.kUnknown_7)
|
||||
{
|
||||
assetsFile.SetVersion(unityVersion);
|
||||
}
|
||||
CheckStrippedVersion(assetsFile);
|
||||
assetsFileList.Add(assetsFile);
|
||||
assetsFileListHash.Add(assetsFile.fileName);
|
||||
}
|
||||
@ -218,6 +221,18 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckStrippedVersion(SerializedFile assetsFile)
|
||||
{
|
||||
if (assetsFile.IsVersionStripped && string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||
{
|
||||
throw new Exception("The Unity version has been stripped, please set the version in the options");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(SpecifyUnityVersion))
|
||||
{
|
||||
assetsFile.SetVersion(SpecifyUnityVersion);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var assetsFile in assetsFileList)
|
||||
|
@ -219,11 +219,14 @@ namespace AssetStudio
|
||||
|
||||
public void SetVersion(string stringVersion)
|
||||
{
|
||||
unityVersion = stringVersion;
|
||||
var buildSplit = Regex.Replace(stringVersion, @"\d", "").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
buildType = new BuildType(buildSplit[0]);
|
||||
var versionSplit = Regex.Replace(stringVersion, @"\D", ".").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
version = versionSplit.Select(int.Parse).ToArray();
|
||||
if (stringVersion != strippedVersion)
|
||||
{
|
||||
unityVersion = stringVersion;
|
||||
var buildSplit = Regex.Replace(stringVersion, @"\d", "").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
buildType = new BuildType(buildSplit[0]);
|
||||
var versionSplit = Regex.Replace(stringVersion, @"\D", ".").Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
version = versionSplit.Select(int.Parse).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private SerializedType ReadSerializedType(bool isRefType)
|
||||
@ -371,6 +374,10 @@ namespace AssetStudio
|
||||
ObjectsDic.Add(obj.m_PathID, obj);
|
||||
}
|
||||
|
||||
public bool IsVersionStripped => unityVersion == strippedVersion;
|
||||
|
||||
private const string strippedVersion = "0.0.0";
|
||||
|
||||
public static bool IsSerializedFile(EndianBinaryReader reader)
|
||||
{
|
||||
var fileSize = reader.BaseStream.Length;
|
||||
|
29
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
29
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
@ -41,6 +41,8 @@
|
||||
this.displayAll = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.enablePreview = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.displayInfo = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem14 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.specifyUnityVersion = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportAllObjectssplitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -210,6 +212,7 @@
|
||||
this.displayAll,
|
||||
this.enablePreview,
|
||||
this.displayInfo,
|
||||
this.toolStripMenuItem14,
|
||||
this.showExpOpt});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21);
|
||||
@ -249,6 +252,20 @@
|
||||
"t, audio bitrate, etc.";
|
||||
this.displayInfo.CheckedChanged += new System.EventHandler(this.displayAssetInfo_Check);
|
||||
//
|
||||
// toolStripMenuItem14
|
||||
//
|
||||
this.toolStripMenuItem14.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.specifyUnityVersion});
|
||||
this.toolStripMenuItem14.Name = "toolStripMenuItem14";
|
||||
this.toolStripMenuItem14.Size = new System.Drawing.Size(223, 22);
|
||||
this.toolStripMenuItem14.Text = "Specify Unity version";
|
||||
//
|
||||
// specifyUnityVersion
|
||||
//
|
||||
this.specifyUnityVersion.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.specifyUnityVersion.Name = "specifyUnityVersion";
|
||||
this.specifyUnityVersion.Size = new System.Drawing.Size(100, 23);
|
||||
//
|
||||
// showExpOpt
|
||||
//
|
||||
this.showExpOpt.Name = "showExpOpt";
|
||||
@ -429,7 +446,7 @@
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(396, 6);
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(281, 6);
|
||||
//
|
||||
// toolStripMenuItem10
|
||||
//
|
||||
@ -438,27 +455,27 @@
|
||||
this.toolStripMenuItem12,
|
||||
this.toolStripMenuItem13});
|
||||
this.toolStripMenuItem10.Name = "toolStripMenuItem10";
|
||||
this.toolStripMenuItem10.Size = new System.Drawing.Size(399, 34);
|
||||
this.toolStripMenuItem10.Size = new System.Drawing.Size(284, 22);
|
||||
this.toolStripMenuItem10.Text = "Asset list to XML";
|
||||
//
|
||||
// toolStripMenuItem11
|
||||
//
|
||||
this.toolStripMenuItem11.Name = "toolStripMenuItem11";
|
||||
this.toolStripMenuItem11.Size = new System.Drawing.Size(270, 34);
|
||||
this.toolStripMenuItem11.Size = new System.Drawing.Size(165, 22);
|
||||
this.toolStripMenuItem11.Text = "All assets";
|
||||
this.toolStripMenuItem11.Click += new System.EventHandler(this.toolStripMenuItem11_Click);
|
||||
//
|
||||
// toolStripMenuItem12
|
||||
//
|
||||
this.toolStripMenuItem12.Name = "toolStripMenuItem12";
|
||||
this.toolStripMenuItem12.Size = new System.Drawing.Size(270, 34);
|
||||
this.toolStripMenuItem12.Size = new System.Drawing.Size(165, 22);
|
||||
this.toolStripMenuItem12.Text = "Selected assets";
|
||||
this.toolStripMenuItem12.Click += new System.EventHandler(this.toolStripMenuItem12_Click);
|
||||
//
|
||||
// toolStripMenuItem13
|
||||
//
|
||||
this.toolStripMenuItem13.Name = "toolStripMenuItem13";
|
||||
this.toolStripMenuItem13.Size = new System.Drawing.Size(270, 34);
|
||||
this.toolStripMenuItem13.Size = new System.Drawing.Size(165, 22);
|
||||
this.toolStripMenuItem13.Text = "Filtered assets";
|
||||
this.toolStripMenuItem13.Click += new System.EventHandler(this.toolStripMenuItem13_Click);
|
||||
//
|
||||
@ -1178,6 +1195,8 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem12;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem13;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem14;
|
||||
private System.Windows.Forms.ToolStripTextBox specifyUnityVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace AssetStudioGUI
|
||||
if (paths.Length > 0)
|
||||
{
|
||||
ResetForm();
|
||||
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
if (paths.Length == 1 && Directory.Exists(paths[0]))
|
||||
{
|
||||
await Task.Run(() => assetsManager.LoadFolder(paths[0]));
|
||||
@ -125,7 +125,6 @@ namespace AssetStudioGUI
|
||||
{
|
||||
await Task.Run(() => assetsManager.LoadFiles(paths));
|
||||
}
|
||||
|
||||
BuildAssetStructures();
|
||||
}
|
||||
}
|
||||
@ -135,6 +134,7 @@ namespace AssetStudioGUI
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
await Task.Run(() => assetsManager.LoadFiles(openFileDialog1.FileNames));
|
||||
BuildAssetStructures();
|
||||
}
|
||||
@ -146,6 +146,7 @@ namespace AssetStudioGUI
|
||||
if (openFolderDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
ResetForm();
|
||||
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
|
||||
await Task.Run(() => assetsManager.LoadFolder(openFolderDialog.Folder));
|
||||
BuildAssetStructures();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user