From fa038260a007b049382911e13b7f77720e524c1c Mon Sep 17 00:00:00 2001 From: atenfyr Date: Mon, 9 Dec 2024 18:16:12 -0600 Subject: [PATCH] SkipParsingExports serialization flag --- UAssetAPI/IO/ZenAsset.cs | 2 +- UAssetAPI/UAsset.cs | 17 +++++++++++------ UAssetAPI/UnrealPackage.cs | 9 ++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/UAssetAPI/IO/ZenAsset.cs b/UAssetAPI/IO/ZenAsset.cs index b770cdb0..7213328d 100644 --- a/UAssetAPI/IO/ZenAsset.cs +++ b/UAssetAPI/IO/ZenAsset.cs @@ -396,7 +396,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in switch (entry.CommandType) { case EExportCommandType.ExportCommandType_Serialize: - ConvertExportToChildExportAndRead(reader, (int)entry.LocalExportIndex); + ParseExport(reader, (int)entry.LocalExportIndex); break; } } diff --git a/UAssetAPI/UAsset.cs b/UAssetAPI/UAsset.cs index d08dccd0..6d2a67f7 100644 --- a/UAssetAPI/UAsset.cs +++ b/UAssetAPI/UAsset.cs @@ -39,7 +39,12 @@ public enum CustomSerializationFlags : int /// /// Skip loading other assets referenced in preload dependencies. You may wish to set this flag when possible in multi-threading applications, since preload dependency loading could lead to file handle race conditions. /// - SkipPreloadDependencyLoading = 4 + SkipPreloadDependencyLoading = 4, + + /// + /// Skip parsing exports at read time. Entries in the export map will still be converted to their respective sub-types. You can manually parse exports with the method. + /// + SkipParsingExports = 8 } @@ -1052,7 +1057,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in } } - if (reader.LoadUexp) + if (reader.LoadUexp && !CustomSerializationFlags.HasFlag(CustomSerializationFlags.SkipParsingExports)) { // load dependencies, if needed and available Dictionary> depsMap = new Dictionary>(); @@ -1101,7 +1106,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in continue; } - ConvertExportToChildExportAndRead(reader, i); + ParseExport(reader, i); } // catch any stragglers @@ -1117,13 +1122,13 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in continue; } - ConvertExportToChildExportAndRead(reader, i); + ParseExport(reader, i); } } } else { - // skip loading dependencies & parsing export data if we don't load uexp + // skip loading dependencies & parsing export data if we don't load uexp/exports // convert all exports as appropriate, but do no further reading for (int i = 0; i < Exports.Count; i++) { @@ -1133,7 +1138,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in continue; } - ConvertExportToChildExportAndRead(reader, i, false); + ParseExport(reader, i, false); } } diff --git a/UAssetAPI/UnrealPackage.cs b/UAssetAPI/UnrealPackage.cs index 5679e92f..864bc7eb 100644 --- a/UAssetAPI/UnrealPackage.cs +++ b/UAssetAPI/UnrealPackage.cs @@ -722,7 +722,14 @@ internal string InternalAssetPath _internalAssetPath = value; } } - protected void ConvertExportToChildExportAndRead(AssetBinaryReader reader, int i, bool read = true) + + /// + /// Read an export from disk. + /// + /// The binary reader. + /// The index of the export in the export map to read. + /// Whether or not to serialize the body of the export. If false, simply convert to the respective sub-type. + public void ParseExport(AssetBinaryReader reader, int i, bool read = true) { #pragma warning disable CS0168 // Variable is declared but never used try