SerializedFile metadata command (Unity version, platform and typetree info)#59
Merged
SkowronskiAndrew merged 18 commits intomainfrom Mar 6, 2026
Merged
SerializedFile metadata command (Unity version, platform and typetree info)#59SkowronskiAndrew merged 18 commits intomainfrom
SkowronskiAndrew merged 18 commits intomainfrom
Conversation
Initial implementation exposes the first few fields (version / platform / EnableTypeTree)
Add 3 variations of a very specific Addressable build This will be used for testing how well UnityDataTool exposes type information
Contributor
There was a problem hiding this comment.
Pull request overview
Adds richer SerializedFile metadata parsing (including TypeTree entry headers for v19–v23) and exposes it via a new serialized-file metadata / sf metadata CLI subcommand, along with test fixtures and NUnit coverage for common TypeTree configurations (inline, extracted, disabled, SerializeReference types).
Changes:
- Introduces
BinaryFileHelper/UnityHash128and extendsSerializedFileDetector.TryParseMetadatato parse TypeTree section counts and per-entry metadata for regular and SerializeReference type lists. - Adds
sf metadatacommand with text + JSON output (including TypeTree arrays in JSON). - Adds/updates test data and NUnit tests for metadata parsing and new CLI behavior.
Reviewed changes
Copilot reviewed 8 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| UnityDataTool/SerializedFileCommands.cs | Adds HandleMetadata plus text/JSON output helpers for new metadata command. |
| UnityDataTool/Program.cs | Registers new serialized-file metadata subcommand (alias sf metadata). |
| UnityDataTool.Tests/SerializedFileCommandTests.cs | Adds initial CLI test coverage for metadata command error path (legacy version). |
| Analyzer/Util/SerializedFileDetector.cs | Adds SerializedFileMetadata / TypeTreeInfo models and implements TypeTree metadata parsing in TryParseMetadata. |
| Analyzer/Util/BinaryFileHelper.cs | Adds shared endian-aware binary helpers and UnityHash128. |
| Analyzer.Tests/FileDetectionTests.cs | Adds NUnit tests validating metadata parsing across representative files; adjusts one archive test path. |
| Documentation/command-serialized-file.md | Documents new metadata subcommand under serialized-file. |
| TestCommon/Data/LegacyFormats/v22_strippedVersion | Adds stripped-version serialized file fixture for metadata parsing scenarios. |
| TestCommon/Data/AssetBundleTypeTreeVariations/README.md | Documents the new typetree-variation fixtures and how to inspect them. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_extracted/prefab_with_serializedreference.serializedfile | Fixture: v23 extracted typetree prefab serializedfile. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_extracted/packedassets_assets_all.bundle | Fixture: v23 extracted typetree main bundle. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_extracted/monoscriptbundle.serializedfile | Fixture: v23 extracted typetree monoscript bundle serializedfile. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_extracted/MonoScript_monoscripts_dde848dc9848681e340a8b4fa9bd7578.bundle | Fixture: v23 extracted typetree autoscript bundle. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_extracted/AssetBundle.typetreedata | Fixture: extracted typetree store archive used by v23 extracted builds. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_Inline/prefab_with_serializedreference.serializedfile | Fixture: v23 inline typetree prefab serializedfile. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_Inline/packedassets_assets_all.bundle | Fixture: v23 inline typetree main bundle. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_Inline/monoscriptbundle.serializedfile | Fixture: v23 inline typetree monoscript bundle serializedfile. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v23_Inline/MonoScript_monoscripts_dde848dc9848681e340a8b4fa9bd7578.bundle | Fixture: v23 inline typetree autoscript bundle. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v22/prefab_with_serializedreference.serializedfile | Fixture: v22 typetree prefab serializedfile (SerializeReference). |
| TestCommon/Data/AssetBundleTypeTreeVariations/v22/packedassets_assets_all.bundle | Fixture: v22 typetree main bundle. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v22/monoscriptbundle.serializedfile | Fixture: v22 typetree monoscript bundle serializedfile. |
| TestCommon/Data/AssetBundleTypeTreeVariations/v22/MonoScript_monoscripts_dde848dc9848681e340a8b4fa9bd7578.bundle | Fixture: v22 typetree autoscript bundle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
And other comment/doc improvements.
This fixes ObjectList for files without TypeTrees
Similar to objectlist change
Final step of fully parsing the metadata section of serialized files
Also update comment based on research into exactly what this is.
This code gets to graduate to its own assembly, it didn't belong in the Analyzer anymore. This makes it cleaner to use from TextDumper and upcoming UnityFileSystem usage
Show extra message when there is no type trees And avoid large unhelpful callstack when printing out errors if it is general Unknown error
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This branch adds a new serialized-file metadata command and expands the depth of metadata parsing in the
UnityDataTool.
New serialized-file metadata Command
A new subcommand that exposes the full metadata section of a Unity serialized file, including:
without type trees
Note: i keep this information separate from "header". One reason is to match how it is actually structured inside SerializedFiles. Another reason is to keep the header command very light weight because we use to check each file before trying to open it. The meta-data command will potentially pull a lot more data.
Note: In this case the Json and text output for the command diverge. I hope this isn't confusing. But it seemed reasonable to keep the text version short and to the point rather than try to express complex arrays in text formats. The json format is more appropriate for the detailed structured representation of the metadata.
Refactoring & Code Quality
dedicated UnityBinaryFormat assembly, making them cleaner to reuse across tools
Test Coverage
Documentation
New subcommand is documented, which also helps explain some of the concepts in these data structures.