-
Notifications
You must be signed in to change notification settings - Fork 63
New "serialized-file" command with docs and new test data #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ad788d0
Add test data from player build
SkowronskiAndrew 04617de
UnityDataTool serialized-file command
SkowronskiAndrew 76ef609
Test data without TypeTree
SkowronskiAndrew 2d8a7a7
Documentation for new serialized-file command
SkowronskiAndrew 1b898f5
Remove importers from the hardcoded typeid list
SkowronskiAndrew 651de27
Small updates from testing
SkowronskiAndrew 3d44693
Fix typo in test UnityDataTool.Tests/SerializedFileCommandTests.cs
SkowronskiAndrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| # serialized-file Command | ||
|
|
||
| The `serialized-file` command (alias: `sf`) provides utilities for quickly inspecting SerializedFile metadata without performing a full analysis. | ||
|
|
||
| ## Sub-Commands | ||
|
|
||
| | Sub-Command | Description | | ||
| |-------------|-------------| | ||
| | [`externalrefs`](#externalrefs) | List external file references | | ||
| | [`objectlist`](#objectlist) | List all objects in the file | | ||
|
|
||
| --- | ||
|
|
||
| ## externalrefs | ||
|
|
||
| Lists the external file references (dependencies) in a SerializedFile. This shows which other files the SerializedFile depends on. | ||
|
|
||
| ### Quick Reference | ||
|
|
||
| ``` | ||
| UnityDataTool serialized-file externalrefs <filename> [options] | ||
| UnityDataTool sf externalrefs <filename> [options] | ||
| ``` | ||
|
|
||
| | Option | Description | Default | | ||
| |--------|-------------|---------| | ||
| | `<filename>` | Path to the SerializedFile | *(required)* | | ||
| | `-f, --format <format>` | Output format: `Text` or `Json` | `Text` | | ||
|
|
||
| ### Example - Text Output | ||
|
|
||
| ```bash | ||
| UnityDataTool serialized-file externalrefs level0 | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| Index: 1, Path: globalgamemanagers.assets | ||
| Index: 2, Path: sharedassets0.assets | ||
| Index: 3, Path: Library/unity default resources | ||
| ``` | ||
|
|
||
| ### Example - JSON Output | ||
|
|
||
| ```bash | ||
| UnityDataTool sf externalrefs sharedassets0.assets --format json | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ```json | ||
| [ | ||
| { | ||
| "index": 1, | ||
| "path": "globalgamemanagers.assets", | ||
| "guid": "00000000000000000000000000000000", | ||
| "type": "NonAssetType" | ||
| }, | ||
| { | ||
| "index": 2, | ||
| "path": "Library/unity default resources", | ||
| "guid": "0000000000000000e000000000000000", | ||
| "type": "NonAssetType" | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## objectlist | ||
|
|
||
| Lists all objects contained in a SerializedFile, showing their IDs, types, offsets, and sizes. | ||
|
|
||
| ### Quick Reference | ||
|
|
||
| ``` | ||
| UnityDataTool serialized-file objectlist <filename> [options] | ||
| UnityDataTool sf objectlist <filename> [options] | ||
| ``` | ||
|
|
||
| | Option | Description | Default | | ||
| |--------|-------------|---------| | ||
| | `<filename>` | Path to the SerializedFile | *(required)* | | ||
| | `-f, --format <format>` | Output format: `Text` or `Json` | `Text` | | ||
|
|
||
| ### Example - Text Output | ||
|
|
||
| ```bash | ||
| UnityDataTool sf objectlist sharedassets0.assets | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ``` | ||
| Id Type Offset Size | ||
| ------------------------------------------------------------------------------------------ | ||
| 1 PreloadData 83872 49 | ||
| 2 Material 83936 268 | ||
| 3 Shader 84208 6964 | ||
| 4 Cubemap 91184 240 | ||
| 5 MonoBehaviour 91424 60 | ||
| 6 MonoBehaviour 91488 72 | ||
| ``` | ||
|
|
||
| ### Example - JSON Output | ||
|
|
||
| ```bash | ||
| UnityDataTool serialized-file objectlist level0 --format json | ||
| ``` | ||
|
|
||
| **Output:** | ||
| ```json | ||
| [ | ||
| { | ||
| "id": 1, | ||
| "typeId": 1, | ||
| "typeName": "GameObject", | ||
| "offset": 4864, | ||
| "size": 132 | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "typeId": 4, | ||
| "typeName": "Transform", | ||
| "offset": 5008, | ||
| "size": 104 | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Use Cases | ||
|
|
||
| ### Quick File Inspection | ||
|
|
||
| Use `serialized-file` when you need quick information about a SerializedFile without generating a full SQLite database: | ||
|
|
||
| ```bash | ||
| # Check what objects are in a file | ||
| UnityDataTool sf objectlist sharedassets0.assets | ||
|
|
||
| # Check file dependencies | ||
| UnityDataTool sf externalrefs level0 | ||
| ``` | ||
|
|
||
| ### Scripting and Automation | ||
|
|
||
| The JSON output format is ideal for scripts and automated processing: | ||
|
|
||
| ```bash | ||
| # Extract object count | ||
| UnityDataTool sf objectlist level0 -f json | jq 'length' | ||
|
|
||
| # Find specific object types | ||
| UnityDataTool sf objectlist sharedassets0.assets -f json | jq '.[] | select(.typeName == "Material")' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## SerializedFile vs Archive | ||
|
|
||
| When working with AssetBundles (or a compressed Player build) you need to extract the contents first (with `archive extract`), then run the `serialized-file` command on individual files in the extracted output. | ||
|
|
||
| **Example workflow:** | ||
| ```bash | ||
| # 1. List contents of an archive | ||
| UnityDataTool archive list scenes.bundle | ||
|
|
||
| # 2. Extract the archive | ||
| UnityDataTool archive extract scenes.bundle -o extracted/ | ||
|
|
||
| # 3. Inspect individual SerializedFiles | ||
| UnityDataTool sf objectlist extracted/CAB-5d40f7cad7c871cf2ad2af19ac542994 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Notes | ||
|
|
||
| - This command only supports extracting information from the SerializedFile header of individual files. It does not extract detailed type-specific properties. Use `analyze` for full analysis of one or more SerializedFiles. | ||
| - The command uses the same native library (UnityFileSystemApi) as other UnityDataTool commands, ensuring consistent file reading across all Unity versions. | ||
|
|
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| This is a partial copy of the same build as PlayerWithTypeTrees, but with typetrees turned off. | ||
|
|
||
| Without typetrees the information that can be retrieved is quite limited. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Test data description | ||
|
|
||
| This is the content output of a Player build, made with Unity 6000.0.65f1. | ||
| The diagnostic switch to enable TypeTrees was enabled when the build was performed. | ||
|
|
||
| The project is very simple and intended to be used for precise tests of expected content. | ||
|
|
||
| ## Content | ||
|
|
||
| The build includes two scene files: | ||
| * SceneWithReferences.unity (level0) uses MonoBehaviours to references BasicScriptableObject.asset and Asset2.asset | ||
| * SceneWithReferences2.unity (level1) uses MonoBehaviours to reference BasicScriptableObject.asset and ScriptableObjectWithSerializeReference.asset | ||
|
|
||
| Based on that sharing arrangement: | ||
| * sharedassets0.assets contains BasicScriptableObject.asset and Asset2.asset | ||
| * sharedassets1.assets contains ScriptableObjectWithSerializeReference.asset | ||
|
|
||
| There are also additional content | ||
| * globalgamemanager with the preference objects | ||
| * globalgamemanager.assets with assets referenced from the globalgamemanager file | ||
| * globalgamemanagers.assets.resS containing the splash screen referenced from globalgamemanager.assets | ||
|
|
||
| Note: The binaries, json files and other output that were also output from the player build are not checked in, because they are not needed by UnityDataTool. | ||
|
|
||
| ## BuildReport | ||
|
|
||
| The LastBuild.buildreport file (created in the Library folder) has also been copied in. | ||
|
|
||
| ## Scripting types | ||
|
|
||
| The MonoBehaviour used in level0 and level1 to reference the ScriptableObject is of type MonoBehaviourWithReference. | ||
|
|
||
| * BasicScriptableObject.asset and Asset2.asset are instances of the BasicScriptableObject class. | ||
| * ScriptableObjectWithSerializeReference.asset is an instance of the MyNamespace.ScriptableObjectWithSerializeReference class. | ||
|
|
||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#55 tracks this "todo"