Skip to content

Commit b6caf1e

Browse files
authored
Added support for specifying an extracted type tree data file (#60)
* Added support for specifying an extracted type tree data file for dump and analyze commands * updated docs & tests * updated UnityFileSystem dlls to 6000.5.0a8 - this version has the API needed to load extracted type tree files. * Bump version to 1.3.3 * Add a few additional AssetBundle test files
1 parent 0f5f050 commit b6caf1e

23 files changed

+337
-42
lines changed

Documentation/command-analyze.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ UnityDataTool analyze <path> [options]
1616
| `-s, --skip-references` | Skip CRC and reference extraction (faster, smaller DB) | `false` |
1717
| `-v, --verbose` | Show more information during analysis | `false` |
1818
| `--no-recurse` | Do not recurse into sub-directories | `false` |
19+
| `-d, --typetree-data <file>` | Load an external TypeTree data file before processing (Unity 6.5+) ||
1920

2021
## Examples
2122

@@ -90,7 +91,13 @@ System.ArgumentException: Invalid object id.
9091

9192
This error occurs when SerializedFiles are built without TypeTrees. The command will skip these files and continue.
9293

93-
**Solution:** Enable **ForceAlwaysWriteTypeTrees** in your Unity build settings. See [Unity Content Format](../../Documentation/unity-content-format.md) for details.
94+
**Solutions:**
95+
- Enable **ForceAlwaysWriteTypeTrees** in your Unity build settings. See [Unity Content Format](../../Documentation/unity-content-format.md) for details.
96+
- If your bundles were built with external TypeTree data (Unity 6.5+), use the `--typetree-data` option to load the TypeTree data file before analysis:
97+
98+
```bash
99+
UnityDataTool analyze /path/to/bundles --typetree-data /path/to/typetree.bin
100+
```
94101

95102
### SQL Constraint Errors
96103

Documentation/command-dump.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ UnityDataTool dump <path> [options]
1515
| `-f, --output-format <format>` | Output format | `text` |
1616
| `-s, --skip-large-arrays` | Skip dumping large arrays | `false` |
1717
| `-i, --objectid <id>` | Only dump object with this ID | All objects |
18+
| `-d, --typetree-data <file>` | Load an external TypeTree data file before processing (Unity 6.5+) ||
1819

1920
## Examples
2021

@@ -87,6 +88,14 @@ UnityDataTool serialized-file metadata /path/to/file
8788

8889
The `TypeTree Definitions` field will show `No` when TypeTrees are absent.
8990

91+
**External TypeTree data (Unity 6.5+):**
92+
93+
If your bundles were built with TypeTree data extracted to a separate file, use the `--typetree-data` option to load it:
94+
95+
```bash
96+
UnityDataTool dump /path/to/file.bundle --typetree-data /path/to/typetree.bin
97+
```
98+
9099
---
91100

92101
## Output Format

Documentation/command-serialized-file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ Each element of `scriptTypes` in the JSON output contains:
305305

306306
Notes:
307307

308-
* For SerializedFiles inside AssetBundles the Unity Version is frequently stripped ("0.0.0"). See [BuildAssetBundleOptions.AssetBundleStripUnityVersion](https://docs.unity3d.com/ScriptReference/BuildAssetBundleOptions.AssetBundleStripUnityVersion.html).
309-
* For AssetBundles the version string may take the form "<version>\n<assetbundle-format-version>". The assetbundle-format-version rarely changes, and is currently 2.
308+
* For SerializedFiles inside AssetBundles the Unity Version can be stripped, in which case the Unity Version value is "0.0.0". See [BuildAssetBundleOptions.AssetBundleStripUnityVersion](https://docs.unity3d.com/ScriptReference/BuildAssetBundleOptions.AssetBundleStripUnityVersion.html).
309+
* For AssetBundles where the typetrees have been stripped out the version string takes the form `<unity-version>\n<assetbundle-format-version>`. The assetbundle-format-version rarely changes, and is currently 2. Examples "6000.0.65f1\n2" and "0.0.0\n2".
310310
* The Unity Editor will attempt to load SerializedFiles regardless of the Platform. But the Runtime will only load files built with the correct platform value.
311311

312312
---

Documentation/unity-content-format.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ Player built content, unless the Player was built with TypeTrees enabled.
8888
>[!TIP]
8989
>The `binary2text` tool supports an optional argument `-typeinfo` to enable dumping out the TypeTrees in a SerializedFile header. That is a useful way to learn more about TypeTrees and to see exactly how Unity data is represented in the binary format.
9090
91+
#### Extracted Typetrees
92+
93+
Starting with Unity 6.5 and Addressables 2.9 it is possible to extract the TypeTrees from all the SerializedFiles in an Addressable build into a shared file. This can reduce the size of the build output, because the TypeTree information is no longer duplicated in each file.
94+
95+
For details see [Addressable AssetBundle memory considerations](https://docs.unity3d.com/Packages/com.unity.addressables@2.9/manual/memory-assetbundles.html)
96+
97+
UnityDataTools commands that open serialized files using the UnityFileSystem API require access to the TypeTrees. For example `dump` and `analyze`. Use the `--typetree-data` option to specify the `.typetreedata` file when examining a build that has extracted TypeTrees.
98+
9199
### Platform details for using UnityDataTool with Player Data
92100

93101
The output structure and file formats for a Unity Player build are quite platform specific.

Documentation/unitydatatool.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ Use `--help` with any command for details: `UnityDataTool analyze --help`
4141

4242
Use `--version` to print the tool version.
4343

44+
## External TypeTree Data
45+
46+
Starting with Unity 6.5, asset bundles can be built with TypeTree data extracted into a separate file. When bundles are built this way, the TypeTree data file must be loaded before the bundles can be processed.
47+
48+
The `--typetree-data` (`-d`) option is available on the [`analyze`](command-analyze.md) and [`dump`](command-dump.md) commands:
49+
50+
```bash
51+
# Analyze bundles that use an external TypeTree data file
52+
UnityDataTool analyze /path/to/bundles --typetree-data /path/to/typetree.bin
53+
54+
# Dump a bundle with external TypeTree data
55+
UnityDataTool dump /path/to/file.bundle -d /path/to/typetree.bin
56+
```
57+
58+
> **Note:** This option requires a version of UnityFileSystemApi from Unity 6.5 or newer. Using it with an older version of the library will produce an error message.
59+
4460

4561
## Installation
4662

Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ManifestFileVersion: 0
2+
UnityVersion: 6000.0.65f1
3+
CRC: 2966982943
4+
HashAppended: 0
5+
AssetBundleManifest:
6+
AssetBundleInfos:
7+
Info_0:
8+
Name: small.bundle
9+
Dependencies: {}
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ManifestFileVersion: 0
2+
UnityVersion: 6000.0.65f1
3+
CRC: 1950084276
4+
Hashes:
5+
AssetFileHash:
6+
serializedVersion: 2
7+
Hash: 85d7a0628d93941ceb548a6dfa4daaa5
8+
TypeTreeHash:
9+
serializedVersion: 2
10+
Hash: 8fe56aa230288d26e5aa9f8e595de7aa
11+
IncrementalBuildHash:
12+
serializedVersion: 2
13+
Hash: 23708f44cf6b8ab8a9a6d6474bc8166a
14+
HashAppended: 0
15+
ClassTypes:
16+
- Class: 114
17+
Script: {fileID: 11500000, guid: 1eb29b0714ed25b4b9acbb23c6791a75, type: 3}
18+
- Class: 115
19+
Script: {instanceID: 0}
20+
SerializeReferenceClassIdentifiers: []
21+
Assets:
22+
- Assets/Assets/BasicScriptableObject.asset
23+
Dependencies: []

0 commit comments

Comments
 (0)