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
Improve Analyze documentation, small code fixes (#25)
Add a new topic to the documentation that gives some example usage of Analyze, for example to run queries on the command line.
Rework the README.md for Analyze library to move the more advanced developer focused information to the bottom. (I think most readers will just want to understand what Analyze does, and only more rare cases will they want to understand the implementation and actually extend library )
Add more details about how to extend the Analyze library to add support for more types.
Trivial code changes:
Remove dead code - SerializedObject base class is not used.
Fix two warnings about unreferenced variables.
Copy file name to clipboardExpand all lines: Analyzer/README.md
+42-28Lines changed: 42 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,37 +4,20 @@ The Analyzer is a class library that can be used to analyze the content of Unity
4
4
as AssetBundles and SerializedFiles. It iterates through all the serialized objects and uses the
5
5
TypeTree to extract information about these objects (e.g. name, size, etc.)
6
6
7
-
The extracted information is forwarded to an object implementing the [IWriter](./IWriter.cs)
8
-
interface. The library provides the [SQLiteWriter](./SQLite/SQLiteWriter.cs) implementation that
9
-
writes the data into a SQLite database.
7
+
The most common use of this library is through the [analyze](../UnityDataTool/README.md#analyzeanalyse)
8
+
command of the UnityDataTool. This uses the Analyze library to generate a SQLite database.
10
9
11
-
It is possible to extract type-specific properties using classes inheriting from the
12
-
[SerializedObject](./SerializedObjects/SerializedObject.cs) class. The project already provides
13
-
the most common SerializedObject implementations in the [SerializedObjects](./SerializedObjects)
14
-
folder.
10
+
Once generated, a tool such as the [DB Browser for SQLite](https://sqlitebrowser.org/), or the command line `sqlite3` tool, can be used to look at the content of the database.
15
11
16
-
# How to use the library
12
+
# Example usage
17
13
18
-
The [AnalyzerTool](./AnalyzerTool.cs) class is the API entry point. The main method is called
19
-
Analyze. It is currently hardcoded to write using the [SQLiteWriter](./SQLite/SQLiteWriter.cs),
20
-
but it can easily be adapter to use another writer type. It takes four parameters:
21
-
* path (string): path of the folder where the files to analyze are located. It will be searched
22
-
recursively.
23
-
* databaseName (string): database filename, it will be overwritten if it already exists.
* skipReferences (bool): determines if the CRC calculation and references (PPtrs) extraction must
26
-
skipped. This is faster, but the refs table will be empty and the duplicate assets won't be
27
-
accurate.
28
-
Calling this method will create the SQLite output database and will recursively
29
-
process the files matching the search pattern in the provided path. It will add a row in
30
-
the 'objects' table for each serialized object. This table contain basic information such as the
31
-
size and the name of the object (if it has one).
32
-
33
-
# How to use the database
34
-
35
-
A tool such as the [DB Browser for SQLite](https://sqlitebrowser.org/) is required to look at the
36
-
content of the database. The database provides different views that can be used to easily find the
37
-
information you might need.
14
+
See [this topic](../Documentation/analyze-examples.md) for examples of how to use the SQLite output of the UnityDataTool Analyze command.
15
+
16
+
# DataBase Reference
17
+
18
+
The database provides different views. The views join multiple tables together and often it is not necessary to write your own SQL queries to find the information you want, especially when you are using a visual SQLite tool.
19
+
20
+
This section gives an overview of the main views.
38
21
39
22
## object_view
40
23
@@ -178,3 +161,34 @@ stripping it won't make a big difference.
178
161
This view lists all the shaders aggregated by name. The *instances* column indicates how many time
179
162
the shader was found in the data files. It also provides the total size per shader and the list of
180
163
AssetBundles in which they were found.
164
+
165
+
# Advanced
166
+
167
+
## Using the library
168
+
169
+
The [AnalyzerTool](./AnalyzerTool.cs) class is the API entry point. The main method is called
170
+
Analyze. It is currently hard coded to write using the [SQLiteWriter](./SQLite/SQLiteWriter.cs),
171
+
but this approach could be extended to add support for other outputs.
172
+
173
+
Calling this method will recursively process the files matching the search pattern in the provided
174
+
path. It will add a row in the 'objects' table for each serialized object. This table contain basic
175
+
information such as the size and the name of the object (if it has one).
176
+
177
+
## Extending the Library
178
+
179
+
The extracted information is forwarded to an object implementing the [IWriter](./IWriter.cs)
180
+
interface. The library provides the [SQLiteWriter](./SQLite/SQLiteWriter.cs) implementation that
181
+
writes the data into a SQLite database.
182
+
183
+
The core properties that apply to all Unity Objects are extracted into the `objects` table.
184
+
However much of the most useful Analyze functionality comes by virtue of the type-specific information that is extracted for
185
+
important types like Meshes, Shaders, Texture2D and AnimationClips. For example, when a Mesh object is encountered in a Serialized
186
+
File, then rows are added to both the `objects` table and the `meshes` table. The meshes table contains columns that only apply to Mesh objects, for example the number of vertices, indices, bones, and channels. The `mesh_view` is a view that joins the `objects` table with the `meshes` table, so that you can see all the properties of a Mesh object in one place.
187
+
188
+
Each supported Unity object type follows the same pattern:
189
+
* A Handler class in the SQLite/Handlers (e.g. [MeshHandler.cs](./SQLite/Handler/MeshHandler.cs).
190
+
* The registration of the handler in the m_Handlers dictionary in [SQLiteWriter.cs](./SQLite/SQLiteWriter.cs).
191
+
* SQL statements defining extra tables and views associated with the type, e.g. [Mesh.sql](./SQLite/Resources/Mesh.sql).
192
+
* A Reader class that uses RandomAccessReader to read properties from the serialized object. e.g. [Mesh.cs](./SerializedObjects/Mesh.cs).
193
+
194
+
It would be possible to extend the Analyze library to add additional columns for the existing types, or by following the same pattern to add additional types. The [dump](../UnityDataTool/README.md#dump) feature of UnityDataTool is a useful way to see the property names and other details of the serialization for a type. Based on that information, code in the Reader class can use the RandomAccessReader to retrieve those properties to bring them into the SQLite database.
0 commit comments