You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document project structure; split Archive and SerializedFile into their own libraries (#88)
* More documentation of the project structure in main README
* Restructure Archive and SerializedFile code into their own libraries
For consistency with the other command implementations - it didn't make much sense that some commands were implemented directly inside UnityDataTool and others as separate libraries.
├── UnityDataModels → schemas for JSON build-report formats
102
+
└── UnityFileSystem → C# wrapper for native library
103
+
└── UnityFileSystemApi (native .dll/.dylib/.so)
99
104
```
100
105
106
+
The feature libraries each build on UnityBinaryFormat and UnityFileSystem. See the
107
+
"Repository content" section of `README.md` for a diagram of the dependencies.
108
+
101
109
### Key Architectural Patterns
102
110
103
111
**Native Interop**: UnityFileSystem wraps UnityFileSystemApi (native library from Unity Editor) via P/Invoke in `DllWrapper.cs`. The native library reads Unity Archive and SerializedFile formats.
UnityBinaryFormat["<b>UnityBinaryFormat</b><br/>C# parsers & helpers<br/>for Archives / SerializedFiles"]
57
+
UnityDataModels["<b>UnityDataModels</b><br/>schemas for build reporting file formats"]
58
+
59
+
CLI --> Analyzer
60
+
CLI --> TextDumper
61
+
CLI --> ReferenceFinder
62
+
CLI --> Archive
63
+
CLI --> SerializedFile
64
+
65
+
Analyzer --> UnityFileSystem
66
+
Analyzer --> UnityBinaryFormat
67
+
Analyzer --> UnityDataModels
68
+
TextDumper --> UnityFileSystem
69
+
TextDumper --> UnityBinaryFormat
70
+
Archive --> UnityFileSystem
71
+
Archive --> UnityBinaryFormat
72
+
SerializedFile --> UnityFileSystem
73
+
SerializedFile --> UnityBinaryFormat
74
+
UnityBinaryFormat --> UnityFileSystem
75
+
76
+
ReferenceFinder -. "reads the SQLite database" .-> Analyzer
77
+
```
78
+
79
+
**Command-line tool**
80
+
*[UnityDataTool](Documentation/unitydatatool.md): the command-line tool. It wires the feature
81
+
libraries together and exposes them as commands (`analyze`, `dump`, `find-refs`, `archive`,
82
+
`serialized-file`, and more), so most users only ever interact with this executable.
83
+
84
+
**Feature libraries**
85
+
*[Analyzer](Documentation/analyzer.md): extracts key information from Unity data files into a SQLite
86
+
database for detailed analysis. It also parses Addressables build reports.
87
+
*[TextDumper](Documentation/textdumper.md): dumps SerializedFiles into a human-readable format
88
+
(similar to Unity's binary2text).
89
+
*[ReferenceFinder](Documentation/referencefinder.md): finds reference chains from one object to
90
+
another by querying a database produced by the Analyzer (a data dependency rather than a code one).
91
+
*[Archive](Documentation/command-archive.md): inspects and extracts the contents of Unity Archives
92
+
(AssetBundles and web platform `.data` files) — the `archive` command.
93
+
*[SerializedFile](Documentation/command-serialized-file.md): inspects the header, metadata, object
94
+
list, and external references of a SerializedFile — the `serialized-file` command.
95
+
96
+
**Base libraries**
97
+
* UnityFileSystem: a .NET class library, with source and binaries, that wraps the native
98
+
`UnityFileSystemApi` to mount Unity Archives and read SerializedFiles.
99
+
* UnityBinaryFormat: C# parsers and helpers for reading data out of Unity Archives and SerializedFiles.
100
+
* UnityDataModels: shared C# models for the reading JSON format files produced by the build (Addressables BuildLayout.json, Content Directory ContentLayout.json).
101
+
102
+
## Purpose of UnityFileSystemApi
103
+
104
+
UnityFileSystemApi is compiled from the Unity source code and exposes the core functionality to open and read the Unity Archive and Serialized File formats as a flexible, performant library. It exposes the ability to navigate the TypeTrees inside a SerializedFile so objects can be read generically, without hardcoded type knowledge.
105
+
106
+
It enables custom tools for binary2text-like output and efficient SQLite database generation.
107
+
108
+
### Tests and test data
109
+
110
+
The automated tests are not shown in the diagram above. Each library has its own test project, and the
111
+
shared test data doubles as convenient sample content for ad hoc use of the tool.
112
+
113
+
* TestCommon: a helper library whose `Data/` folder holds small reference files extracted from real
114
+
Unity builds (Player, AssetBundles, content directory etc). These back the automated tests and are also handy for trying out the tool by hand.
115
+
* Analyzer.Tests, UnityDataTool.Tests, UnityFileSystem.Tests: the per-library test suites.
116
+
* UnityProjects: two Unity projects (`Baseline` and `LeadingEdge`) used to regenerate some of the test
117
+
data as Unity evolves.
53
118
54
119
## Downloads
55
120
@@ -63,7 +128,7 @@ Refer to the [commit history](https://github.com/Unity-Technologies/UnityDataToo
63
128
64
129
## Getting UnityFileSystemApi
65
130
66
-
UnityDataTool uses the native`UnityFileSystemApi` library to read Unity Archives and SerializedFiles. **Normally you don't need to do anything with this library.** The repository already includes a recent Windows, Mac, and Linux copy in the [`UnityFileSystem/`](https://github.com/Unity-Technologies/UnityDataTools/tree/main/UnityFileSystem) directory, and using that bundled copy is the recommended way to run the tool.
131
+
UnityDataTool uses the pre-compiled`UnityFileSystemApi` library to read Unity Archives and SerializedFiles. **Normally you don't need to do anything with this library.** The repository already includes a recent Windows, Mac, and Linux copy in the [`UnityFileSystem/`](https://github.com/Unity-Technologies/UnityDataTools/tree/main/UnityFileSystem) directory, and using that bundled copy is the recommended way to run the tool.
67
132
68
133
The library is backward compatible but not forward compatible: a given version can read content from the same or older Unity versions, but may be unable to read content produced by a newer Unity Editor than the library itself. The bundled copy is updated periodically as Unity evolves, so in practice it can read content from just about any Unity version.
69
134
@@ -84,10 +149,6 @@ On Windows, the executable is written to `UnityDataTool\bin\Release\net9.0`. Add
84
149
85
150
See the [command-line tool documentation](./Documentation/unitydatatool.md) for usage instructions.
86
151
87
-
## Purpose of UnityFileSystemApi
88
-
89
-
UnityFileSystemApi exposes the core functionality of WebExtract and binary2text to open and read the Unity Archive and Serialized File formats, exposed as a flexible, performant library. It enables custom tools for binary2text-like output and efficient SQLite database generation.
90
-
91
152
## Origins
92
153
93
154
This tool is the evolution of the [AssetBundle Analyzer](https://github.com/faelenor/asset-bundle-analyzer)
0 commit comments