mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-15 19:28:48 -05:00
Rework options a bit
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using AssetStudio.Addons.CubismLive2D;
|
||||
using AssetStudio.CustomOptions;
|
||||
using AssetStudio.CustomOptions.Asmo;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -16,16 +15,14 @@ namespace AssetStudio
|
||||
{
|
||||
public class AssetsManager
|
||||
{
|
||||
public bool LoadViaTypeTree = true;
|
||||
public bool MeshLazyLoad = true;
|
||||
public UnityVersion AutoLegacyVersion = null;
|
||||
public ImportOptions Options = new ImportOptions();
|
||||
public readonly List<Action<OptionsFile>> OptionLoaders = new List<Action<OptionsFile>>();
|
||||
public readonly AssetsManagerOptions Options = new AssetsManagerOptions();
|
||||
public readonly List<SerializedFile> AssetsFileList = new List<SerializedFile>();
|
||||
|
||||
internal Dictionary<string, int> assetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
internal ConcurrentDictionary<string, BinaryReader> resourceFileReaders = new ConcurrentDictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
||||
internal UnityVersion AutoLegacyVersion = null;
|
||||
internal Dictionary<string, int> AssetsFileIndexCache = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
internal ConcurrentDictionary<string, BinaryReader> ResourceFileReaders = new ConcurrentDictionary<string, BinaryReader>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly List<Action<OptionsFile>> optionLoaders = new List<Action<OptionsFile>>();
|
||||
private readonly List<string> importFiles = new List<string>();
|
||||
private readonly HashSet<ClassIDType> filteredAssetTypesList = new HashSet<ClassIDType>();
|
||||
private readonly HashSet<string> importFilesHash = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -34,7 +31,17 @@ namespace AssetStudio
|
||||
|
||||
public AssetsManager()
|
||||
{
|
||||
OptionLoaders.Add(LoadImportOptions);
|
||||
AddOptionsLoader(Options.LoadGameSpecificOptionsFromFile);
|
||||
}
|
||||
|
||||
public void AddOptionsLoader(Action<OptionsFile> loader)
|
||||
{
|
||||
optionLoaders.Add(loader);
|
||||
}
|
||||
|
||||
public void ClearOptionLoaders()
|
||||
{
|
||||
optionLoaders.Clear();
|
||||
}
|
||||
|
||||
public void SetAssetFilter(params ClassIDType[] classIDTypes)
|
||||
@@ -291,7 +298,7 @@ namespace AssetStudio
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Warning($"Failed to read assets file \"{reader.FullPath}\" from {Path.GetFileName(originalPath)}\n{e}");
|
||||
resourceFileReaders.TryAdd(reader.FileName, reader);
|
||||
ResourceFileReaders.TryAdd(reader.FileName, reader);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -375,7 +382,7 @@ namespace AssetStudio
|
||||
}
|
||||
else
|
||||
{
|
||||
resourceFileReaders.TryAdd(file.fileName, subReader);
|
||||
ResourceFileReaders.TryAdd(file.fileName, subReader);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -403,7 +410,7 @@ namespace AssetStudio
|
||||
LoadWebFile(subReader);
|
||||
break;
|
||||
case FileType.ResourceFile:
|
||||
resourceFileReaders.TryAdd(file.fileName, subReader);
|
||||
ResourceFileReaders.TryAdd(file.fileName, subReader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -504,7 +511,7 @@ namespace AssetStudio
|
||||
if (entryReader.FileType == FileType.ResourceFile)
|
||||
{
|
||||
entryReader.Position = 0;
|
||||
resourceFileReaders.TryAdd(entry.Name, entryReader);
|
||||
ResourceFileReaders.TryAdd(entry.Name, entryReader);
|
||||
}
|
||||
Progress.Report(++k, progressCount);
|
||||
}
|
||||
@@ -542,7 +549,7 @@ namespace AssetStudio
|
||||
if (optionsFile == null)
|
||||
continue;
|
||||
|
||||
foreach (var optionsLoader in OptionLoaders)
|
||||
foreach (var optionsLoader in optionLoaders)
|
||||
{
|
||||
optionsLoader(optionsFile);
|
||||
}
|
||||
@@ -572,34 +579,18 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadImportOptions(OptionsFile optionsFile)
|
||||
private void CheckStrippedVersion(SerializedFile assetsFile, UnityVersion bundleUnityVer = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var importOptions = ImportOptions.FromOptionsFile(optionsFile);
|
||||
if (importOptions == null)
|
||||
return;
|
||||
Options = importOptions;
|
||||
Logger.Info("Import options successfully loaded.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Warning($"Error while reading import options\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckStrippedVersion(SerializedFile assetsFile, UnityVersion bundleUnityVer = null)
|
||||
{
|
||||
if (assetsFile.version.IsStripped && Options.CustomUnityVersion == null)
|
||||
if (assetsFile.version.IsStripped && Options.GameSpecific.CustomUnityVersion == null)
|
||||
{
|
||||
var msg = "The asset's Unity version has been stripped, please set the version in the options.";
|
||||
if (bundleUnityVer != null && !bundleUnityVer.IsStripped)
|
||||
msg += $"\n\nAssumed Unity version based on asset bundle: {bundleUnityVer}";
|
||||
throw new NotSupportedException(msg);
|
||||
}
|
||||
if (Options.CustomUnityVersion != null)
|
||||
if (Options.GameSpecific.CustomUnityVersion != null)
|
||||
{
|
||||
assetsFile.version = Options.CustomUnityVersion;
|
||||
assetsFile.version = Options.GameSpecific.CustomUnityVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,19 +603,19 @@ namespace AssetStudio
|
||||
}
|
||||
AssetsFileList.Clear();
|
||||
|
||||
foreach (var resourceFileReader in resourceFileReaders)
|
||||
foreach (var resourceFileReader in ResourceFileReaders)
|
||||
{
|
||||
resourceFileReader.Value.Close();
|
||||
}
|
||||
resourceFileReaders.Clear();
|
||||
ResourceFileReaders.Clear();
|
||||
|
||||
assetsFileIndexCache.Clear();
|
||||
AssetsFileIndexCache.Clear();
|
||||
}
|
||||
|
||||
private void ReadAssets()
|
||||
{
|
||||
var serializedVer = AssetsFileList[0].header.m_Version;
|
||||
if (serializedVer <= SerializedFileFormatVersion.Unknown_6 && serializedVer >= SerializedFileFormatVersion.Unknown_5 && AutoLegacyVersion == null && Options.CustomUnityVersion == null)
|
||||
if (serializedVer <= SerializedFileFormatVersion.Unknown_6 && serializedVer >= SerializedFileFormatVersion.Unknown_5 && AutoLegacyVersion == null && Options.GameSpecific.CustomUnityVersion == null)
|
||||
{
|
||||
var versions = serializedVer == SerializedFileFormatVersion.Unknown_6
|
||||
? "'2.1.0f1', '2.5.0f1', '2.6.0f1'"
|
||||
@@ -650,8 +641,10 @@ namespace AssetStudio
|
||||
Progress.Reset();
|
||||
foreach (var assetsFile in AssetsFileList)
|
||||
{
|
||||
if (AutoLegacyVersion != null && Options.CustomUnityVersion == null)
|
||||
if (AutoLegacyVersion != null && Options.GameSpecific.CustomUnityVersion == null)
|
||||
{
|
||||
assetsFile.version = AutoLegacyVersion;
|
||||
}
|
||||
|
||||
JsonConverterHelper.AssetsFile = assetsFile;
|
||||
foreach (var objectInfo in assetsFile.m_Objects)
|
||||
@@ -664,14 +657,14 @@ namespace AssetStudio
|
||||
try
|
||||
{
|
||||
Object obj = null;
|
||||
var loadViaTypeTree = objectReader.serializedType?.m_Type != null && LoadViaTypeTree;
|
||||
var parseByTypeTree = objectReader.serializedType?.m_Type != null && Options.ParseByTypeTree;
|
||||
switch (objectReader.type)
|
||||
{
|
||||
case ClassIDType.Animation:
|
||||
obj = new Animation(objectReader);
|
||||
break;
|
||||
case ClassIDType.AnimationClip when objectReader.version >= (1, 5):
|
||||
obj = loadViaTypeTree
|
||||
obj = parseByTypeTree
|
||||
? new AnimationClip(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions, objectInfo)
|
||||
: new AnimationClip(objectReader);
|
||||
break;
|
||||
@@ -703,7 +696,7 @@ namespace AssetStudio
|
||||
obj = new GameObject(objectReader);
|
||||
break;
|
||||
case ClassIDType.Material:
|
||||
obj = loadViaTypeTree
|
||||
obj = parseByTypeTree
|
||||
? new Material(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions)
|
||||
: new Material(objectReader);
|
||||
break;
|
||||
@@ -752,12 +745,12 @@ namespace AssetStudio
|
||||
obj = new TextAsset(objectReader);
|
||||
break;
|
||||
case ClassIDType.Texture2D:
|
||||
obj = loadViaTypeTree
|
||||
obj = parseByTypeTree
|
||||
? new Texture2D(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions)
|
||||
: new Texture2D(objectReader);
|
||||
break;
|
||||
case ClassIDType.Texture2DArray:
|
||||
obj = loadViaTypeTree
|
||||
obj = parseByTypeTree
|
||||
? new Texture2DArray(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions)
|
||||
: new Texture2DArray(objectReader);
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using AssetStudio.CustomOptions;
|
||||
using AssetStudio.CustomOptions.Asmo;
|
||||
using System;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
public class AssetsManagerOptions
|
||||
{
|
||||
public readonly GameSpecificOptions GameSpecific = new GameSpecificOptions();
|
||||
|
||||
public bool ParseByTypeTree { get; set; } = true;
|
||||
public bool MeshPreProcessing { get; set; }
|
||||
public bool DecompressToDisk { get; set; }
|
||||
public string CustomCachePath { get; set; }
|
||||
|
||||
internal void LoadGameSpecificOptionsFromFile(OptionsFile optionsFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GameSpecific.FromFile(optionsFile))
|
||||
return;
|
||||
|
||||
Logger.Info("Game-specific options successfully loaded.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Warning($"Error while reading the game-specific options\n{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using AssetStudio.CustomOptions;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -45,7 +44,7 @@ namespace AssetStudio
|
||||
{
|
||||
public readonly bool IsDataAfterBundle;
|
||||
private static TempFileStream _sharedTempFileStream;
|
||||
private readonly ImportOptions.CustomBundleOptions _bundleOptions;
|
||||
private readonly AssetsManagerOptions _studioOptions;
|
||||
|
||||
public class Header
|
||||
{
|
||||
@@ -78,9 +77,9 @@ namespace AssetStudio
|
||||
private StorageBlock[] m_BlocksInfo;
|
||||
private Node[] m_DirectoryInfo;
|
||||
|
||||
public BundleFile(FileReader reader, ImportOptions importOptions, bool isMultiBundle = false)
|
||||
public BundleFile(FileReader reader, AssetsManagerOptions studioOptions, bool isMultiBundle = false)
|
||||
{
|
||||
_bundleOptions = importOptions.BundleOptions;
|
||||
_studioOptions = studioOptions;
|
||||
m_Header = new Header();
|
||||
m_Header.signature = reader.ReadStringToNull();
|
||||
m_Header.version = reader.ReadUInt32();
|
||||
@@ -113,7 +112,7 @@ namespace AssetStudio
|
||||
IsDataAfterBundle = streamSize - bundleSize > 200;
|
||||
|
||||
var unityVer = m_Header.unityRevision;
|
||||
var customUnityVer = importOptions.CustomUnityVersion;
|
||||
var customUnityVer = studioOptions.GameSpecific.CustomUnityVersion;
|
||||
if (customUnityVer != null)
|
||||
{
|
||||
if (!unityVer.IsStripped && customUnityVer != unityVer)
|
||||
@@ -181,12 +180,12 @@ namespace AssetStudio
|
||||
private Stream CreateBlocksStream()
|
||||
{
|
||||
var uncompressedSizeSum = m_BlocksInfo.Sum(x => x.uncompressedSize);
|
||||
if (uncompressedSizeSum < int.MaxValue && !_bundleOptions.DecompressToDisk)
|
||||
if (uncompressedSizeSum < int.MaxValue && !_studioOptions.DecompressToDisk)
|
||||
return new MemoryStream((int)uncompressedSizeSum);
|
||||
|
||||
if (_sharedTempFileStream == null || !_sharedTempFileStream.CanRead)
|
||||
{
|
||||
var cachePath = _bundleOptions.CustomCachePath;
|
||||
var cachePath = _studioOptions.CustomCachePath;
|
||||
if (string.IsNullOrEmpty(cachePath) || !Directory.Exists(cachePath))
|
||||
{
|
||||
throw new NotSupportedException("Cache directory wasn't found. Make sure that the specified path is correct.");
|
||||
@@ -306,7 +305,7 @@ namespace AssetStudio
|
||||
blocksInfoBytes = reader.ReadBytes(compressedSize);
|
||||
}
|
||||
|
||||
var customBlockInfoCompression = _bundleOptions.CustomBlockInfoCompression;
|
||||
var customBlockInfoCompression = _studioOptions.GameSpecific.Bundles.CustomBlockInfoCompression;
|
||||
var compressionType = (CompressionType)(m_Header.flags & ArchiveFlags.CompressionTypeMask);
|
||||
if (customBlockInfoCompression == CompressionType.Auto)
|
||||
{
|
||||
@@ -408,7 +407,7 @@ namespace AssetStudio
|
||||
|
||||
private Stream ReadBlocks(FileReader reader)
|
||||
{
|
||||
var customBlockCompression = _bundleOptions.CustomBlockCompression;
|
||||
var customBlockCompression = _studioOptions.GameSpecific.Bundles.CustomBlockCompression;
|
||||
var blocksStream = CreateBlocksStream();
|
||||
var blocksCompression = m_BlocksInfo.Max(x => (CompressionType)(x.flags & StorageBlockFlags.CompressionTypeMask));
|
||||
var blockSize = (int)m_BlocksInfo.Max(x => x.uncompressedSize);
|
||||
|
||||
@@ -745,9 +745,9 @@ namespace AssetStudio
|
||||
var m_KeepIndices = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
var tuanjieParsingMode = reader.assetsFile.assetsManager.Options.MeshOptions.TuanjieMeshParsingMode;
|
||||
var useSharedClusterData = tuanjieParsingMode == ImportOptions.CustomMeshOptions.MeshParsingMode.Tuanjie
|
||||
|| (tuanjieParsingMode == ImportOptions.CustomMeshOptions.MeshParsingMode.Auto && reader.version < (2022, 3, 61, 2));
|
||||
var tuanjieParsingMode = reader.assetsFile.assetsManager.Options.GameSpecific.Meshes.TuanjieMeshParsingMode;
|
||||
var useSharedClusterData = tuanjieParsingMode == GameSpecificOptions.CustomMeshOptions.MeshParsingMode.Tuanjie
|
||||
|| (tuanjieParsingMode == GameSpecificOptions.CustomMeshOptions.MeshParsingMode.Auto && reader.version < (2022, 3, 61, 2));
|
||||
if (version.IsTuanjie && useSharedClusterData)
|
||||
{
|
||||
if (version < (2022, 3, 48, 3)) //2022.3.48t3(1.4.0) down
|
||||
@@ -932,7 +932,7 @@ namespace AssetStudio
|
||||
|
||||
//m_MeshLodInfo = new MeshLodInfo(reader) //6000.2 and up
|
||||
|
||||
if (!assetsFile.assetsManager.MeshLazyLoad)
|
||||
if (assetsFile.assetsManager.Options.MeshPreProcessing)
|
||||
ProcessData();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace AssetStudio
|
||||
{
|
||||
var assetsManager = _assetsFile.assetsManager;
|
||||
var assetsFileList = assetsManager.AssetsFileList;
|
||||
var assetsFileIndexCache = assetsManager.assetsFileIndexCache;
|
||||
var assetsFileIndexCache = assetsManager.AssetsFileIndexCache;
|
||||
|
||||
if (_index == -2)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace AssetStudio
|
||||
|
||||
var assetsManager = _assetsFile.assetsManager;
|
||||
var assetsFileList = assetsManager.AssetsFileList;
|
||||
var assetsFileIndexCache = assetsManager.assetsFileIndexCache;
|
||||
var assetsFileIndexCache = assetsManager.AssetsFileIndexCache;
|
||||
|
||||
if (!assetsFileIndexCache.TryGetValue(name, out _index))
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace AssetStudio.CustomOptions.Asmo
|
||||
{
|
||||
public class OptionsFile
|
||||
{
|
||||
private static readonly byte[] OptionsFileSign = new byte[] { 0x41, 0x53, 0x4D, 0x4F }; //ASMO
|
||||
private static readonly byte[] OptionsFileSign = { 0x41, 0x53, 0x4D, 0x4F }; //ASMO
|
||||
public static readonly string Extension = ".asmo";
|
||||
|
||||
public byte[] Signature { get; private set; } = OptionsFileSign;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
namespace AssetStudio.CustomOptions
|
||||
{
|
||||
public partial class ImportOptions
|
||||
public partial class GameSpecificOptions
|
||||
{
|
||||
public sealed class CustomBundleOptions
|
||||
{
|
||||
private CompressionType _customBlockCompression = CompressionType.Auto;
|
||||
private CompressionType _customBlockInfoCompression = CompressionType.Auto;
|
||||
private string _customCachePath;
|
||||
private bool _decompressToDisk;
|
||||
|
||||
public CompressionType CustomBlockCompression
|
||||
{
|
||||
@@ -21,18 +19,6 @@
|
||||
set => _customBlockInfoCompression = SetOption(nameof(CustomBlockInfoCompression), value, _customBlockInfoCompression);
|
||||
}
|
||||
|
||||
public string CustomCachePath
|
||||
{
|
||||
get => _customCachePath;
|
||||
set => _customCachePath = SetOption(nameof(CustomCachePath), value, _customCachePath);
|
||||
}
|
||||
|
||||
public bool DecompressToDisk
|
||||
{
|
||||
get => _decompressToDisk;
|
||||
set => _decompressToDisk = SetOption(nameof(DecompressToDisk), value, _decompressToDisk);
|
||||
}
|
||||
|
||||
public CustomBundleOptions() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace AssetStudio.CustomOptions
|
||||
{
|
||||
public partial class ImportOptions
|
||||
public partial class GameSpecificOptions
|
||||
{
|
||||
public sealed class CustomMeshOptions
|
||||
{
|
||||
|
||||
+23
-13
@@ -8,19 +8,19 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetStudio.CustomOptions
|
||||
{
|
||||
public partial class ImportOptions
|
||||
public partial class GameSpecificOptions
|
||||
{
|
||||
private static JsonSerializerOptions jsonOptions;
|
||||
private static string fileName = "ImportOptions";
|
||||
private static string fileName = "GameOptions";
|
||||
private UnityVersion _customUnityVer;
|
||||
|
||||
public event EventHandler UnityVersionChanged;
|
||||
|
||||
public CustomBundleOptions BundleOptions { get; set; }
|
||||
public CustomMeshOptions MeshOptions { get; set; }
|
||||
public CustomBundleOptions Bundles { get; set; }
|
||||
public CustomMeshOptions Meshes { get; set; }
|
||||
public UnityVersion CustomUnityVersion { get => _customUnityVer; set => SetUnityVersion(value); }
|
||||
|
||||
static ImportOptions()
|
||||
static GameSpecificOptions()
|
||||
{
|
||||
jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
@@ -29,19 +29,19 @@ namespace AssetStudio.CustomOptions
|
||||
};
|
||||
}
|
||||
|
||||
public ImportOptions()
|
||||
public GameSpecificOptions()
|
||||
{
|
||||
BundleOptions = new CustomBundleOptions();
|
||||
MeshOptions = new CustomMeshOptions();
|
||||
Bundles = new CustomBundleOptions();
|
||||
Meshes = new CustomMeshOptions();
|
||||
CustomUnityVersion = null;
|
||||
}
|
||||
|
||||
public static ImportOptions FromOptionsFile(OptionsFile optionsFile)
|
||||
public bool FromFile(OptionsFile optionsFile)
|
||||
{
|
||||
if (optionsFile.Reserved != 0)
|
||||
{
|
||||
Logger.Debug("Skipped. Not an import options file.");
|
||||
return null;
|
||||
Logger.Debug("Skipped. Not a GameOptions file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var utf8Bytes = Convert.FromBase64String(Encoding.ASCII.GetString(optionsFile.Data));
|
||||
@@ -49,7 +49,12 @@ namespace AssetStudio.CustomOptions
|
||||
if (optionsFile.DataCrc != dataCrc)
|
||||
throw new IOException("Options file data is corrupted.");
|
||||
|
||||
return JsonSerializer.Deserialize<ImportOptions>(utf8Bytes, jsonOptions);
|
||||
var parsedOptions = JsonSerializer.Deserialize<GameSpecificOptions>(utf8Bytes, jsonOptions);
|
||||
Bundles = parsedOptions.Bundles;
|
||||
Meshes = parsedOptions.Meshes;
|
||||
CustomUnityVersion = parsedOptions.CustomUnityVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SaveToFile(string outputFolder)
|
||||
@@ -78,6 +83,7 @@ namespace AssetStudio.CustomOptions
|
||||
{
|
||||
if (_customUnityVer == value)
|
||||
return;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
_customUnityVer = null;
|
||||
@@ -85,6 +91,7 @@ namespace AssetStudio.CustomOptions
|
||||
Logger.Info("- Specified Unity version: None");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(value.BuildType))
|
||||
{
|
||||
throw new NotSupportedException("Specified Unity version is not in a correct format.\n" +
|
||||
@@ -92,7 +99,10 @@ namespace AssetStudio.CustomOptions
|
||||
"Example: 2022.3.2f1");
|
||||
}
|
||||
_customUnityVer = value;
|
||||
UnityVersionChanged?.Invoke(this, EventArgs.Empty);
|
||||
if (UnityVersionChanged == null)
|
||||
return;
|
||||
|
||||
UnityVersionChanged.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Logger.Info($"- Specified Unity version: {_customUnityVer}");
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace AssetStudio
|
||||
if (needSearch)
|
||||
{
|
||||
var resourceFileName = Path.GetFileName(path);
|
||||
if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader))
|
||||
if (assetsFile.assetsManager.ResourceFileReaders.TryGetValue(resourceFileName, out reader))
|
||||
{
|
||||
needSearch = false;
|
||||
return reader;
|
||||
@@ -63,12 +63,12 @@ namespace AssetStudio
|
||||
if (File.Exists(resourceFilePath))
|
||||
{
|
||||
needSearch = false;
|
||||
if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader))
|
||||
if (assetsFile.assetsManager.ResourceFileReaders.TryGetValue(resourceFileName, out reader))
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
reader = new BinaryReader(File.OpenRead(resourceFilePath));
|
||||
assetsFile.assetsManager.resourceFileReaders.TryAdd(resourceFileName, reader);
|
||||
assetsFile.assetsManager.ResourceFileReaders.TryAdd(resourceFileName, reader);
|
||||
return reader;
|
||||
}
|
||||
throw new FileNotFoundException($"Can't find the resource file {resourceFileName}");
|
||||
|
||||
@@ -91,13 +91,13 @@ namespace AssetStudio
|
||||
var verStr = reader.ReadStringToNull();
|
||||
if (!UnityVersion.TryParse(verStr, out version))
|
||||
{
|
||||
if (assetsManager.Options.CustomUnityVersion == null)
|
||||
if (assetsManager.Options.GameSpecific.CustomUnityVersion == null)
|
||||
{
|
||||
Logger.Warning($"Failed to parse Unity version: \"{verStr}\"");
|
||||
version = new UnityVersion();
|
||||
return;
|
||||
}
|
||||
version = assetsManager.Options.CustomUnityVersion;
|
||||
version = assetsManager.Options.GameSpecific.CustomUnityVersion;
|
||||
reader.Position = versionPos + version.ToString().Length + 1;
|
||||
}
|
||||
}
|
||||
@@ -463,7 +463,7 @@ namespace AssetStudio
|
||||
foreach (var hashStr in hashes)
|
||||
{
|
||||
var serializedType = ExtractedTypeTreeHashes[hashStr];
|
||||
if (assetsManager.resourceFileReaders.TryGetValue(hashStr, out var binaryReader))
|
||||
if (assetsManager.ResourceFileReaders.TryGetValue(hashStr, out var binaryReader))
|
||||
{
|
||||
var fileReader = (FileReader)binaryReader;
|
||||
fileReader.Endian = EndianType.LittleEndian;
|
||||
|
||||
Reference in New Issue
Block a user