-
Notifications
You must be signed in to change notification settings - Fork 62
Established individual topic for each UnityDataTool command #43
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,136 @@ | ||||||
| # analyze Command | ||||||
|
|
||||||
| The `analyze` command extracts information from Unity Archives (e.g. AssetBundles) and SerializedFiles and dumps the results into a SQLite database. | ||||||
|
|
||||||
| ## Quick Reference | ||||||
|
|
||||||
| ``` | ||||||
| UnityDataTool analyze <path> [options] | ||||||
| ``` | ||||||
|
|
||||||
| | Option | Description | Default | | ||||||
| |--------|-------------|---------| | ||||||
| | `<path>` | Path to folder containing files to analyze | *(required)* | | ||||||
| | `-o, --output-file <file>` | Output database filename | `database.db` | | ||||||
| | `-p, --search-pattern <pattern>` | File search pattern (`*` and `?` supported) | `*` | | ||||||
| | `-s, --skip-references` | Skip CRC and reference extraction (faster, smaller DB) | `false` | | ||||||
| | `-v, --verbose` | Show more information during analysis | `false` | | ||||||
| | `--no-recurse` | Do not recurse into sub-directories | `false` | | ||||||
|
|
||||||
| ## Examples | ||||||
|
|
||||||
| Analyze all files in a directory: | ||||||
| ```bash | ||||||
| UnityDataTool analyze /path/to/asset/bundles | ||||||
| ``` | ||||||
|
|
||||||
| Analyze only `.bundle` files and specify a custom database name: | ||||||
| ```bash | ||||||
| UnityDataTool analyze /path/to/asset/bundles -o my_database.db -p "*.bundle" | ||||||
| ``` | ||||||
|
|
||||||
| Fast analysis (skip reference tracking): | ||||||
| ```bash | ||||||
| UnityDataTool analyze /path/to/bundles -s | ||||||
| ``` | ||||||
|
|
||||||
| See also [Analyze Examples](../../Documentation/analyze-examples.md). | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## What Can Be Analyzed | ||||||
|
|
||||||
| The analyze command works with the following types of directories: | ||||||
|
|
||||||
| | Input Type | Description | | ||||||
| |------------|-------------| | ||||||
| | **AssetBundle build output** | The output path of an AssetBundle build | | ||||||
| | **Addressables folder** | `StreamingAssets/aa` folder from a Player build, including BuildLayout files | | ||||||
| | **Entities content** | `StreamingAssets/ContentArchives` folder for [Entities](https://docs.unity3d.com/Packages/[email protected]/manual/content-management-intro.html) projects | | ||||||
| | **Player Data folder** | The `Data` folder of a Unity Player build | | ||||||
| | **Compressed Player builds** | The `data.unity3d` file will be analyzed like AssetBundles | | ||||||
| | **BuildReport files** | The build report is typically found at a path like `Library/LastBuild.buildreport`and is a binary serialized file | | ||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| | **AssetDatabase Artifacts** | The tool will work to some extent with serialized files created in the AssetDatabase artifact storage, inside the Library folder | | ||||||
|
|
||||||
| > **Note**: Some platforms require extracting content from platform-specific containers first (e.g., `.apk` files on Android). | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Output Database | ||||||
|
|
||||||
| The analysis creates a SQLite database that can be explored using tools like [DB Browser for SQLite](https://sqlitebrowser.org/) or the command line `sqlite3` tool. | ||||||
|
|
||||||
| **Refer to the [Analyzer documentation](../../Analyzer/README.md) for the database schema reference and information about extending this command.** | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Troubleshooting | ||||||
|
|
||||||
| ### File Loading Warnings | ||||||
|
|
||||||
| ``` | ||||||
| Failed to load 'C:\....\MyData.db'. File may be corrupted or was serialized with a newer version of Unity. | ||||||
| ``` | ||||||
|
|
||||||
| These warnings occur when the tool encounters non-Unity files in the analyzed directory. They are usually harmless—the analyze process continues and produces a valid database. | ||||||
|
|
||||||
| **Solutions:** | ||||||
| - Use `-p "*.bundle"` to filter by file extension | ||||||
| - Use `--no-recurse` to limit directory depth | ||||||
| - Use `-v` (verbose) to see which files are ignored | ||||||
|
|
||||||
| The tool automatically ignores common non-Unity file types (`.txt`, `.json`, `.manifest`, etc.). | ||||||
|
|
||||||
| ### TypeTree Errors | ||||||
|
|
||||||
| ``` | ||||||
| Error processing file: C:\...\TestProject_Data\level0 | ||||||
| System.ArgumentException: Invalid object id. | ||||||
| ``` | ||||||
|
|
||||||
| This error occurs when SerializedFiles are built without TypeTrees. The command will skip these files and continue. | ||||||
|
|
||||||
| **Solution:** Enable **ForceAlwaysWriteTypeTrees** in your Unity build settings. See [Unity Content Format](../../Documentation/unity-content-format.md) for details. | ||||||
|
|
||||||
| ### SQL Constraint Errors | ||||||
|
|
||||||
| ``` | ||||||
| SQLite Error 19: 'UNIQUE constraint failed: objects.id' | ||||||
| ``` | ||||||
| or | ||||||
| ``` | ||||||
| SQLite Error 19: 'UNIQUE constraint failed: serialized_files.id'. | ||||||
| ``` | ||||||
|
|
||||||
| These errors occur when the same serialized file name appears in multiple sources: | ||||||
|
|
||||||
| | Cause | Solution | | ||||||
| |-------|----------| | ||||||
| | Multiple builds in same directory | Analyze each build separately | | ||||||
| | Scenes with same filename (different paths) | Rename scenes to be unique | | ||||||
| | AssetBundle variants | Analyze variants separately | | ||||||
|
|
||||||
| See [Comparing Builds](../../Documentation/comparing-builds.md) for strategies to compare different versions of builds. | ||||||
|
|
||||||
| ### Slow Analyze times, large output database | ||||||
|
|
||||||
| Consider using the `--skip-references` argument. | ||||||
|
|
||||||
| A real life analyze of a big Addressables build shows how large a difference this can make: | ||||||
|
|
||||||
| * 208 seconds and producted a 500MB database (not specifying --skip-reference) | ||||||
|
||||||
| * 208 seconds and producted a 500MB database (not specifying --skip-reference) | |
| * 208 seconds and produced a 500MB database (not specifying --skip-reference) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||
| # archive Command | ||||||
|
|
||||||
| The `archive` command provides utilities for working with Unity Archives (AssetBundles and web platform `.data` files). | ||||||
|
|
||||||
| ## Sub-Commands | ||||||
|
|
||||||
| | Sub-Command | Description | | ||||||
| |-------------|-------------| | ||||||
| | [`list`](#list) | List contents of an archive | | ||||||
| | [`extract`](#extract) | Extract contents of an archive | | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## list | ||||||
|
|
||||||
| Lists the SerializedFiles contained within an archive. | ||||||
|
|
||||||
| ### Quick Reference | ||||||
|
|
||||||
| ``` | ||||||
| UnityDataTool archive list <archive-path> | ||||||
| ``` | ||||||
|
|
||||||
| ### Example | ||||||
|
|
||||||
| ```bash | ||||||
| UnityDataTool archive list scenes.bundle | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## extract | ||||||
|
|
||||||
| Extracts the contents of an archive to disk. This is similar to Unity's `WebExtract` tool. | ||||||
|
|
||||||
| ### Quick Reference | ||||||
|
|
||||||
| ``` | ||||||
| UnityDataTool archive extract <archive-path> [options] | ||||||
| ``` | ||||||
|
|
||||||
| | Option | Description | Default | | ||||||
| |--------|-------------|---------| | ||||||
| | `<archive-path>` | Path to the archive file | *(required)* | | ||||||
| | `-o, --output-path <path>` | Output directory | `archive` | | ||||||
|
|
||||||
| ### Example | ||||||
|
|
||||||
| ```bash | ||||||
| UnityDataTool archive extract scenes.bundle -o contents | ||||||
| ``` | ||||||
|
|
||||||
| **Output files:** | ||||||
| ``` | ||||||
| contents/BuildPlayer-SampleScene.sharedAssets | ||||||
| contents/BuildPlayer-SampleScene | ||||||
| contents/BuildPlayer-Scene2.sharedAssets | ||||||
| contents/BuildPlayer-Scene2 | ||||||
| ``` | ||||||
|
|
||||||
| > **Note:** The extracted files are binary SerializedFiles, not text. Use the [`dump`](dump.md) command to convert them to readable text format. | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Comparison: extract vs dump | ||||||
|
|
||||||
| | Command | Output | Use Case | | ||||||
| |---------|--------|----------| | ||||||
| | `archive extract` | Binary SerializedFiles, .resS anything else inside the archive content | When you need all the raw files inside an archive | | ||||||
|
||||||
| | `archive extract` | Binary SerializedFiles, .resS anything else inside the archive content | When you need all the raw files inside an archive | | |
| | `archive extract` | Binary SerializedFiles, .resS files, and anything else inside the archive content | When you need all the raw files inside an archive | |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||
| # dump Command | ||||||
|
|
||||||
| The `dump` command converts Unity SerializedFiles into human-readable text format. This is useful for inspecting the internal structure and properties of Unity assets. | ||||||
|
|
||||||
| ## Quick Reference | ||||||
|
|
||||||
| ``` | ||||||
| UnityDataTool dump <path> [options] | ||||||
| ``` | ||||||
|
|
||||||
| | Option | Description | Default | | ||||||
| |--------|-------------|---------| | ||||||
| | `<path>` | Path to file to dump | *(required)* | | ||||||
| | `-o, --output-path <path>` | Output folder | Current folder | | ||||||
| | `-f, --output-format <format>` | Output format | `text` | | ||||||
| | `-s, --skip-large-arrays` | Skip dumping large arrays | `false` | | ||||||
| | `-i, --objectid <id>` | Only dump object with this ID | All objects | | ||||||
|
|
||||||
| ## Examples | ||||||
|
|
||||||
| Dump all objects in a file to the current directory: | ||||||
| ```bash | ||||||
| UnityDataTool dump /path/to/file | ||||||
| ``` | ||||||
|
|
||||||
| Dump to a specific output folder: | ||||||
| ```bash | ||||||
| UnityDataTool dump /path/to/file -o /path/to/output | ||||||
| ``` | ||||||
|
|
||||||
| Dump a single object by ID: | ||||||
| ```bash | ||||||
| UnityDataTool dump /path/to/file -i 1234567890 | ||||||
| ``` | ||||||
|
|
||||||
| Skip large arrays for cleaner output: | ||||||
| ```bash | ||||||
| UnityDataTool dump /path/to/file -s | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Archive Support | ||||||
|
|
||||||
| When you pass an Archive file (like an AssetBundle), the command dumps all SerializedFiles inside. | ||||||
|
|
||||||
| **Example:** For an AssetBundle `scenes.bundle` containing two scenes: | ||||||
|
|
||||||
| ```bash | ||||||
| UnityDataTool dump scenes.bundle | ||||||
| ``` | ||||||
|
|
||||||
| **Output files:** | ||||||
| ``` | ||||||
| BuildPlayer-SampleScene.sharedAssets.txt | ||||||
| BuildPlayer-SampleScene.txt | ||||||
| BuildPlayer-Scene2.sharedAssets.txt | ||||||
| BuildPlayer-Scene2.txt | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Output Format | ||||||
|
|
||||||
| The output is similar to Unity's `binary2text` tool. Each file begins with external references: | ||||||
|
|
||||||
| ``` | ||||||
| External References | ||||||
| path(1): "Library/unity default resources" GUID: 0000000000000000e000000000000000 Type: 0 | ||||||
| path(2): "Resources/unity_builtin_extra" GUID: 0000000000000000f000000000000000 Type: 0 | ||||||
| path(3): "archive:/CAB-35fce856128a6714740898681ea54bbe/..." GUID: 00000000000000000000000000000000 Type: 0 | ||||||
| ``` | ||||||
|
|
||||||
| Followed by object entries: | ||||||
|
|
||||||
| ``` | ||||||
| ID: -8138362113332287275 (ClassID: 135) SphereCollider | ||||||
| m_GameObject PPtr<GameObject> | ||||||
| m_FileID int 0 | ||||||
| m_PathID SInt64 -1473921323670530447 | ||||||
| m_Material PPtr<PhysicMaterial> | ||||||
| m_FileID int 0 | ||||||
| m_PathID SInt64 0 | ||||||
| m_IsTrigger bool False | ||||||
| m_Enabled bool True | ||||||
| m_Radius float 0.5 | ||||||
| m_Center Vector3f | ||||||
| x float 0 | ||||||
| y float 0 | ||||||
| z float 0 | ||||||
| ``` | ||||||
|
|
||||||
| **Refer to the [TextDumper documentation](../../TextDumper/README.md) for detailed output format explanation.** | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Understanding PPtrs | ||||||
|
|
||||||
| PPtrs (Property Pointers) are Unity's mechanism for referencing objects: | ||||||
|
|
||||||
| | Field | Description | | ||||||
| |-------|-------------| | ||||||
| | `m_FileID` | Index into External References list (0 = same file) | | ||||||
| | `m_PathID` | Object's Local File Identifier (LFID) in that file | | ||||||
|
|
||||||
| A null reference will have value m_FileID = 0, m_PathID = 0 | ||||||
|
||||||
| A null reference will have value m_FileID = 0, m_PathID = 0 | |
| A null reference will have values m_FileID = 0, m_PathID = 0 |
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.
Missing space between backtick and 'and'. Should be
Library/LastBuild.buildreportand is a binary serialized file.