Skip to content

Commit fdfdaf1

Browse files
committed
Docs: Addressables example for local-to-remote explicit dependencies
Add SQLite example query and narrative for finding explicit addressables in locally classified bundles that depend on explicit addressables in remote bundles, using build layout JSON from analyze. Update addressables-build-reports schema notes and cross-link to the example. Made-with: Cursor
1 parent 32a31e4 commit fdfdaf1

2 files changed

Lines changed: 109 additions & 10 deletions

File tree

Documentation/addressables-build-reports.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ Contains groups used in the build and whether they're pack separate or together.
5151

5252
#### `addressables_build_group_schemas`
5353
Map groups to their schemas
54-
* schema_rid maps to addressables_group_schemas.id
54+
* schema_rid maps to addressables_build_schemas.id
5555
* group_id maps to addressables_build_groups.id
5656

5757
#### `addressables_build_schemas`
5858
Contain schema names.
59-
* id maps to addressables_group_schemas.id
59+
* id maps to addressables_build_schemas.id
6060

61-
#### `add_build_schema_data_pairs`
61+
#### `addressables_build_schema_data_pairs`
6262
Contains key value pairs of schema settings at time of build.
6363
* schema_id maps to addressables_build_schemas.id
6464

@@ -83,8 +83,8 @@ Explicit assets (marked as Addressable). Has Addressable name and asset informat
8383

8484
#### `addressables_build_explicit_asset_internal_referenced_other_assets`
8585
Map explicit assets to other assets they refer to. For instance a prefab to its underlying FBX
86-
* referencing_asset_rid maps to addressables_build_explicit_assets.id
87-
* data_from_other_asset_Id maps to addressables_build_data_from_other_assets.id
86+
* explicit_asset_id maps to addressables_build_explicit_assets.id
87+
* internal_referenced_other_asset_rid maps to addressables_build_data_from_other_assets.id
8888

8989
#### `addressables_build_data_from_other_assets`
9090
Assets added into the build implicitly by explicitly defined assets.
@@ -110,6 +110,10 @@ UnityDataTools.exe "C:\\Temp\\MyExtractedFiles" -o "addressables_analysis.db" -p
110110

111111
You can analyze a directory with both asset bundles (*.bundle) and json files (*.json) at the same time.
112112

113+
### Cross-group dependencies (local → remote)
114+
115+
To find explicit addressable assets whose bundle is classified as **local** (for example by `load_path`) but that depend on explicit addressables in **remote** bundles, see [Example: Local Addressable groups depending on remote groups](analyze-examples.md#example-local-addressable-groups-depending-on-remote-groups) in analyze-examples.md.
116+
113117
### Sample Queries
114118

115119
Once the data is in the database, you can run queries to analyze your Addressables build:
@@ -118,12 +122,13 @@ Once the data is in the database, you can run queries to analyze your Addressabl
118122
#### Find all implicit assets for an explicit asset
119123
```sql
120124
-- Find implicitly included assets for a given explicit asset id
121-
SELECT a.explicit_asset_id, b.id, b.asset_path, b.asset_path
122-
FROM addressables_build_explicit_asset_internal_referenced_other_assets a,
125+
SELECT a.explicit_asset_id, b.id, b.asset_path
126+
FROM addressables_build_explicit_asset_internal_referenced_other_assets a,
123127
addressables_build_data_from_other_assets b
124-
WHERE a.internal_referenced_other_asset_rid = b.id
125-
AND a.build_id = b.build_id;
126-
AND a.explicit_asset_id = 5092
128+
WHERE a.internal_referenced_other_asset_rid = b.id
129+
AND a.build_id = b.build_id
130+
AND b.build_id = a.build_id
131+
AND a.explicit_asset_id = 5092
127132
AND a.build_id = 3;
128133
```
129134

Documentation/analyze-examples.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,100 @@ Shader Graphs/CustomLightingBuildingsB 113.4 KB 1b2fdfe013c58ffd57d7663
6868

6969
See [buildreport.md](buildreport.md) for information about using analyze to look at BuildReport files.
7070

71+
## Example: Local Addressable groups depending on remote groups
72+
73+
Addressables build layout JSON (for example under `Library\com.unity.addressables\BuildReports\`) records which **explicit** addressable assets reference other **explicit** addressables, including references that cross bundles and groups. That information is stored in SQLite when you run **analyze** on those reports; see [addressables-build-reports.md](addressables-build-reports.md) for schema overview.
74+
75+
UnityDataTools does **not** store a boolean “local” or “remote” flag. In practice, each bundle row has a **`load_path`** string from the build report (table `addressables_build_bundles`). You can classify bundles for a given project by testing that string—for example:
76+
77+
* **Remote bundle:** `load_path` starts with `https://` or `http://` (typical for remote profiles).
78+
* **Local bundle:** not matched by the above (often paths containing `{UnityEngine.AddressableAssets.Addressables.RuntimePath}` or similar). You may refine this for your naming or add conditions such as non-empty `load_path` if you need to exclude odd rows.
79+
80+
Reference edges you care about for “local asset depends on remote explicit addressable” come from two tables (both keyed by `build_id`):
81+
82+
* `addressables_build_explicit_asset_externally_referenced_assets` — from the layout’s **ExternallyReferencedAssets** list.
83+
* `addressables_build_explicit_asset_internal_referenced_explicit_assets` — from **InternalReferencedExplicitAssets**.
84+
85+
Together, these cover explicit-to-explicit dependencies the report encodes (for example prefabs in a local group referencing materials in a remote group). Dependencies that only appear as non-addressable “other” assets are in `addressables_build_explicit_asset_internal_referenced_other_assets` and `addressables_build_data_from_other_assets`; use those if you need implicit dependency closure.
86+
87+
**1. Produce a database from your build reports** (adjust paths; on Windows use backslashes or quoted paths):
88+
89+
```
90+
UnityDataTool analyze "C:\YourProject\Library\com.unity.addressables\BuildReports" -o addressables_analysis.db
91+
```
92+
93+
**2. Find the `build_id`** for the report you care about (often the latest row):
94+
95+
```
96+
sqlite3 addressables_analysis.db "SELECT id, name, start_time FROM addressables_builds ORDER BY id DESC LIMIT 5;"
97+
```
98+
99+
Use that `id` as `:build_id` in the query below.
100+
101+
**3. List explicit assets in a local bundle that reference an explicit asset in a remote bundle**
102+
103+
The following uses a `UNION ALL` of the two explicit-explicit edge tables. Replace `1` with your `build_id`. Bundle `load_path` values are joined only so the `WHERE` clause can classify local vs remote bundles; they are not selected in the result. Column aliases **`local_*`** refer to the asset in the locally classified bundle (the referencing side), and **`remote_*`** to the depended-on asset in the remotely classified bundle. The **`dependency_type`** column uses short labels aligned with typical Addressables UI wording: **`explicit`** for edges from **ExternallyReferencedAssets**, and **`implicit`** for edges from **InternalReferencedExplicitAssets**. In both cases the dependency is still between **explicit addressables** in the build layout; non-addressable “other” assets are modeled separately in `addressables_build_explicit_asset_internal_referenced_other_assets` / `addressables_build_data_from_other_assets`.
104+
105+
```sql
106+
SELECT
107+
'explicit' AS dependency_type,
108+
src.addressable_name AS local_address,
109+
src.asset_path AS local_asset_path,
110+
sg.name AS local_group_name,
111+
tgt.addressable_name AS remote_address,
112+
tgt.asset_path AS remote_asset_path,
113+
tg.name AS remote_group_name
114+
FROM addressables_build_explicit_asset_externally_referenced_assets x
115+
JOIN addressables_build_explicit_assets src
116+
ON src.id = x.explicit_asset_id AND src.build_id = x.build_id
117+
JOIN addressables_build_explicit_assets tgt
118+
ON tgt.id = x.externally_referenced_asset_rid AND tgt.build_id = x.build_id
119+
JOIN addressables_build_bundles sb
120+
ON sb.id = src.bundle AND sb.build_id = src.build_id
121+
JOIN addressables_build_bundles tb
122+
ON tb.id = tgt.bundle AND tb.build_id = tgt.build_id
123+
JOIN addressables_build_groups sg
124+
ON sg.guid = src.group_guid AND sg.build_id = src.build_id
125+
JOIN addressables_build_groups tg
126+
ON tg.guid = tgt.group_guid AND tg.build_id = tgt.build_id
127+
WHERE x.build_id = 1
128+
AND NOT (COALESCE(sb.load_path, '') LIKE 'https://%' OR COALESCE(sb.load_path, '') LIKE 'http://%')
129+
AND (COALESCE(tb.load_path, '') LIKE 'https://%' OR COALESCE(tb.load_path, '') LIKE 'http://%')
130+
131+
UNION ALL
132+
133+
SELECT
134+
'implicit' AS dependency_type,
135+
src.addressable_name AS local_address,
136+
src.asset_path AS local_asset_path,
137+
sg.name AS local_group_name,
138+
tgt.addressable_name AS remote_address,
139+
tgt.asset_path AS remote_asset_path,
140+
tg.name AS remote_group_name
141+
FROM addressables_build_explicit_asset_internal_referenced_explicit_assets iref
142+
JOIN addressables_build_explicit_assets src
143+
ON src.id = iref.explicit_asset_id AND src.build_id = iref.build_id
144+
JOIN addressables_build_explicit_assets tgt
145+
ON tgt.id = iref.internal_referenced_explicit_asset_rid AND tgt.build_id = iref.build_id
146+
JOIN addressables_build_bundles sb
147+
ON sb.id = src.bundle AND sb.build_id = src.build_id
148+
JOIN addressables_build_bundles tb
149+
ON tb.id = tgt.bundle AND tb.build_id = tgt.build_id
150+
JOIN addressables_build_groups sg
151+
ON sg.guid = src.group_guid AND sg.build_id = src.build_id
152+
JOIN addressables_build_groups tg
153+
ON tg.guid = tgt.group_guid AND tg.build_id = tgt.build_id
154+
WHERE iref.build_id = 1
155+
AND NOT (COALESCE(sb.load_path, '') LIKE 'https://%' OR COALESCE(sb.load_path, '') LIKE 'http://%')
156+
AND (COALESCE(tb.load_path, '') LIKE 'https://%' OR COALESCE(tb.load_path, '') LIKE 'http://%');
157+
```
158+
159+
To print results from the command line:
160+
161+
```
162+
sqlite3 addressables_analysis.db ".mode column" ".headers on" "<paste query with build_id adjusted>"
163+
```
164+
71165
## Example: Using AI tools to help write queries
72166

73167
This is not a tutorial on using AI tools. However one useful tip:

0 commit comments

Comments
 (0)