Skip to content

Commit

Permalink
SkipParsingExports serialization flag
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Dec 10, 2024
1 parent ff22022 commit fa03826
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion UAssetAPI/IO/ZenAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
17 changes: 11 additions & 6 deletions UAssetAPI/UAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public enum CustomSerializationFlags : int
/// <summary>
/// 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.
/// </summary>
SkipPreloadDependencyLoading = 4
SkipPreloadDependencyLoading = 4,

/// <summary>
/// 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 <see cref="UnrealPackage.ParseExport(AssetBinaryReader, int)"/> method.
/// </summary>
SkipParsingExports = 8
}


Expand Down Expand Up @@ -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<int, IList<int>> depsMap = new Dictionary<int, IList<int>>();
Expand Down Expand Up @@ -1101,7 +1106,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in
continue;
}

ConvertExportToChildExportAndRead(reader, i);
ParseExport(reader, i);
}

// catch any stragglers
Expand All @@ -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++)
{
Expand All @@ -1133,7 +1138,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in
continue;
}

ConvertExportToChildExportAndRead(reader, i, false);
ParseExport(reader, i, false);
}
}

Expand Down
9 changes: 8 additions & 1 deletion UAssetAPI/UnrealPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,14 @@ internal string InternalAssetPath
_internalAssetPath = value;
}
}
protected void ConvertExportToChildExportAndRead(AssetBinaryReader reader, int i, bool read = true)

/// <summary>
/// Read an export from disk.
/// </summary>
/// <param name="reader">The binary reader.</param>
/// <param name="i">The index of the export in the export map to read.</param>
/// <param name="read">Whether or not to serialize the body of the export. If false, simply convert to the respective sub-type.</param>
public void ParseExport(AssetBinaryReader reader, int i, bool read = true)
{
#pragma warning disable CS0168 // Variable is declared but never used
try
Expand Down

0 comments on commit fa03826

Please sign in to comment.