added option to support version stripped files, close #766

This commit is contained in:
Perfare
2021-06-29 10:32:19 +08:00
parent 973a1076e4
commit c1cddce031
4 changed files with 55 additions and 13 deletions
+16 -1
View File
@@ -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)