Skip to content

Commit 8a78d09

Browse files
[#97] Add Unity scenes to LeadingEdge reference builds
1 parent d930e40 commit 8a78d09

43 files changed

Lines changed: 1243 additions & 241 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/contentdirectory-format.md‎

Lines changed: 85 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ runtime.
5252

5353
Every build artifact is named by the hash of its own content:
5454

55-
- **Content Files** use the `.cf` extension (for example `a77f98db89b6aa1aeaaad01d857e5115.cf`).
55+
- **Content Files** use the `.cf` extension (for example `c0152db4dd710be51b2decb997325f34.cf`).
5656
- **`.resS`** files hold streamed texture and mesh data.
5757
- **`.resource`** files hold audio and video data.
5858

@@ -73,7 +73,7 @@ are present both for loose files and for entries packed inside an archive.
7373
### The build manifest
7474

7575
The build manifest is a JSON file, also named by its content hash (for example
76-
`15d5df98d98434e67e06716cfabfad1b.json`). It records everything needed to load the content: the list of
76+
`baff06b928d147276f2245dd3b19216a.json`). It records everything needed to load the content: the list of
7777
Content Files, their dependencies, and the loadable objects and scenes. Its schema is internal and may
7878
change substantially, so this page does not document it. Instead, use
7979
[`ContentLayout.json`](contentlayout.md), which presents the same information (plus source-asset
@@ -106,7 +106,7 @@ many files contain just a single Unity object (a Material, Shader, Texture, Audi
106106
few grouping rules shape the result:
107107

108108
- **Scenes and Prefabs** store their whole GameObject/Component hierarchy together in a single Content
109-
File, just as they are represented in the Editor.
109+
File, just as they are represented in the Editor (see [Scenes](#scenes) below).
110110
- **Assets with sub-assets** are split across multiple Content Files. For example an FBX is separated
111111
so that the component hierarchy and the meshes land in different files.
112112
- **Scripts** are grouped: the `MonoScript` objects for several source scripts can share one Content
@@ -121,6 +121,71 @@ flagged as built-in (with no content hash); references to it resolve through the
121121
resource mechanism and the `PersistentManager`, rather than through the `ContentLoadManager` that
122122
manages Content Files.
123123

124+
## Scenes
125+
126+
Content directory builds can include Unity Scenes. The build parameters only accept ScriptableObject
127+
assets as roots, so a scene enters the build by being referenced through a `LoadableSceneId` field (a
128+
small serializable struct identifying the scene) on an asset reachable from the roots. Every scene
129+
referenced this way is added to the output, along with the assets the scene itself references. At
130+
runtime, such a scene is loaded with `SceneManager.LoadSceneAsync(LoadableSceneId)` once the content
131+
directory is registered.
132+
133+
Each scene produces exactly one Content File, containing only the scene's own GameObject/Component
134+
hierarchy and scene settings objects. The assets the scene references (textures, materials, and so
135+
on) are not packed with it — they land in their own Content Files following the normal
136+
[granularity rules](#build-layout-granularity), and the scene's file reaches them through the
137+
manifest dependency list. This differs from Player builds, where each scene comes with companion
138+
`sharedassets` files holding its assets. Scene Content Files also differ in their object IDs: the
139+
scene's objects get small sequential IDs (1, 2, 3, ...), rather than the 64-bit hash-based IDs used
140+
in other Content Files.
141+
142+
In `ContentLayout.json` (schema details on the [ContentLayout.json](contentlayout.md) page), the
143+
top-level `LoadableSceneIds` array lists each scene with its source path and the Content File that
144+
holds it. From the reference build in `TestCommon/Data/LeadingEdgeBuilds`, which includes two small
145+
scenes:
146+
147+
```json
148+
"LoadableSceneIds": [
149+
{ "GUID": "590cfeb4e0ff90f4e92f9e1262bcfe6f", "Path": "Assets/Scenes/Scene2.unity", "SerializedFile": 6 },
150+
{ "GUID": "162c015549f8733449ac70ae78ad3aa5", "Path": "Assets/Scenes/Scene1.unity", "SerializedFile": 2 }
151+
]
152+
```
153+
154+
The scene's own `SerializedFiles` entry names the scene as its single source asset, and its symbolic
155+
`ID` is derived from the scene's GUID:
156+
157+
```json
158+
{
159+
"Index": 2,
160+
"ID": "162c015549f8733449ac70ae78ad3aa5.cfid",
161+
"SourceAssets": [ "Assets/Scenes/Scene1.unity" ],
162+
"SerializedFileDependencies": [ 0, 1, 9 ],
163+
"ContentHash": "c271b85494f5e4cc35c4ec4a776324af"
164+
}
165+
```
166+
167+
So this scene lives in `c271b85494f5e4cc35c4ec4a776324af.cf`, and depends on three other files: the
168+
built-in resources entry, the Content File built from `Resources/unity_builtin_extra` (the default
169+
sprite material), and the file holding the Sprite it shows.
170+
171+
A `LoadableSceneId` reference is an on-demand reference, like a `Loadable`: loading the referencing
172+
file does not load the scene. The file holding the reference records the scene by path in its
173+
`LoadableSceneDependencies`, not in `SerializedFileDependencies`, and nothing appears in its
174+
external-reference table — the serialized `LoadableSceneId` field itself only holds the scene's
175+
GUID. The reference build's `SceneList` asset, a ScriptableObject with a dictionary of
176+
`LoadableSceneId` values, shows this:
177+
178+
```json
179+
{
180+
"Index": 7,
181+
"ID": "70a210050f71a924aa83be7146547111.cfid",
182+
"SourceAssets": [ "Assets/ScriptableObjects/SceneList.asset" ],
183+
"SerializedFileDependencies": [ 8 ],
184+
"LoadableSceneDependencies": [ "Assets/Scenes/Scene2.unity", "Assets/Scenes/Scene1.unity" ],
185+
"ContentHash": "8ad4924ac5e264fde63d8e95a0dab8ab"
186+
}
187+
```
188+
124189
## Build history
125190

126191
Every Player and content directory build in Unity 6.6 and later records a **build history** — a set
@@ -157,26 +222,27 @@ ordered list of the files it depends on:
157222

158223
```json
159224
{
160-
"Index": 3,
225+
"Index": 5,
161226
"ID": "52b43dad178849b42ac753005736e7bb.cfid",
162227
"SourceAssets": [ "Assets/ScriptableObjects/ContentDirectoryRoot.asset" ],
163-
"SerializedFileDependencies": [ 4, 2, 6, 7 ],
164-
"ContentHash": "a77f98db89b6aa1aeaaad01d857e5115"
228+
"SerializedFileDependencies": [ 8, 4, 11, 13, 7 ],
229+
"ContentHash": "c0152db4dd710be51b2decb997325f34"
165230
}
166231
```
167232

168-
The `ContentHash` tells us this asset lives in `a77f98db89b6aa1aeaaad01d857e5115.cf`. Dumping that file
233+
The `ContentHash` tells us this asset lives in `c0152db4dd710be51b2decb997325f34.cf`. Dumping that file
169234
shows the object's references and the file's external-reference table:
170235

171236
```
172-
UnityDataTool dump --stdout a77f98db89b6aa1aeaaad01d857e5115.cf
237+
UnityDataTool dump --stdout c0152db4dd710be51b2decb997325f34.cf
173238
```
174239
```
175240
External References
176241
path(1): "a2a42d71dddef12e8889849faf59bdd7.cfid" GUID: 00000000000000000000000000000000 Type: 0
177242
path(2): "4038ff673d390134d924b57fcbed0432.cfid" GUID: 00000000000000000000000000000000 Type: 0
178243
path(3): "21679be819d6e9146a63bb02a7e51f2f.cfid" GUID: 00000000000000000000000000000000 Type: 0
179244
path(4): "78532141fd7679a458405eb16bdb75fd.cfid" GUID: 00000000000000000000000000000000 Type: 0
245+
path(5): "70a210050f71a924aa83be7146547111.cfid" GUID: 00000000000000000000000000000000 Type: 0
180246
181247
ID: -775554941117088049 (ClassID: 114) MonoBehaviour
182248
...
@@ -196,29 +262,29 @@ through the build. A key goal of the content directory design is to reduce the a
196262

197263
Because of that, the content of the external table is effectively ignored by the loading system for
198264
Content File references. What counts is the ordered dependency list in the manifest. The
199-
`"SerializedFileDependencies": [4, 2, 6, 7]` array corresponds, in exact size and order, to the four
200-
entries of the external table.
265+
`"SerializedFileDependencies": [8, 4, 11, 13, 7]` array corresponds, in exact size and order, to the
266+
five entries of the external table.
201267

202268
So resolving the reference to `SingleAudioClipLoadableReference` above:
203269

204270
1. The `PPtr` has `m_FileID` 3. A non-zero `m_FileID` is a 1-based index into the external table (0
205271
would mean "this same file").
206-
2. Index 3 maps to the 3rd entry of `SerializedFileDependencies`, which is `6`.
207-
3. `ContentLayout.json` entry with `"Index": 6` is `SingleAudioClipLoadableReference.asset`, whose
272+
2. Index 3 maps to the 3rd entry of `SerializedFileDependencies`, which is `11`.
273+
3. `ContentLayout.json` entry with `"Index": 11` is `SingleAudioClipLoadableReference.asset`, whose
208274
`ContentHash` is `5c43454a3823f172a2a326410a36ba6b`.
209275
4. The referenced file is therefore `5c43454a3823f172a2a326410a36ba6b.cf`.
210276

211-
The full mapping for this file, showing how each `m_FileID` in the external table resolves through the
212-
dependency list `[4, 2, 6, 7]` to a content-hash filename:
277+
A partial mapping for this file, showing how `m_FileID` values in the external table resolve through
278+
the dependency list `[8, 4, 11, 13, 7]` to a content-hash filename:
213279

214280
```mermaid
215281
flowchart TD
216-
Root["<b>ContentDirectoryRoot</b><br/>cfid 52b43dad…<br/>file a77f98db….cf<br/>deps [4, 2, 6, 7]"]
217-
Loadable["<b>LoadableAudioClipReference</b><br/>Index 2 · cfid 4038ff67…<br/>file bfcf18a2….cf"]
218-
Single["<b>SingleAudioClipLoadableReference</b><br/>Index 6 · cfid 21679be8…<br/>file 5c43454a….cf"]
282+
Root["<b>ContentDirectoryRoot</b><br/>cfid 52b43dad…<br/>file c0152db4….cf<br/>deps [8, 4, 11, 13, 7]"]
283+
Loadable["<b>LoadableAudioClipReference</b><br/>Index 4 · cfid 4038ff67…<br/>file bfcf18a2….cf"]
284+
Single["<b>SingleAudioClipLoadableReference</b><br/>Index 11 · cfid 21679be8…<br/>file 5c43454a….cf"]
219285
220-
Root -->|"m_FileID 2 → dep 2 → Index 2"| Loadable
221-
Root -->|"m_FileID 3 → dep 6 → Index 6"| Single
286+
Root -->|"m_FileID 2 → dep 4 → Index 4"| Loadable
287+
Root -->|"m_FileID 3 → dep 11 → Index 11"| Single
222288
```
223289

224290
> [!NOTE]
29 Bytes
Binary file not shown.

‎TestCommon/Data/LeadingEdgeBuilds/AssetBundles/AssetBundles.manifest‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ManifestFileVersion: 0
2-
UnityVersion: 6000.6.0b3
3-
CRC: 3235539447
2+
UnityVersion: 6000.6.0b5
3+
CRC: 3421127840
44
HashAppended: 0
55
AssetBundleManifest:
66
AssetBundleInfos:
@@ -28,3 +28,6 @@ AssetBundleManifest:
2828
Info_5:
2929
Name: a
3030
Dependencies: {}
31+
Info_6:
32+
Name: scenes
33+
Dependencies: {}
240 KB
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ManifestFileVersion: 0
2+
UnityVersion: 6000.6.0b5
3+
CRC: 2898964469
4+
Hashes:
5+
AssetFileHash:
6+
serializedVersion: 2
7+
Hash: d8376e25b646b14d36812f6e9b0b1eaa
8+
TypeTreeHash:
9+
serializedVersion: 2
10+
Hash: ac9f267e89a2ef550e0850cabce2b0d3
11+
IncrementalBuildHash:
12+
serializedVersion: 2
13+
Hash: 219f878f01ce3e202ce41dc4589c7036
14+
HashAppended: 0
15+
ClassTypes:
16+
- Class: 1
17+
Script: {instanceID: 0}
18+
- Class: 4
19+
Script: {instanceID: 0}
20+
- Class: 21
21+
Script: {instanceID: 0}
22+
- Class: 28
23+
Script: {instanceID: 0}
24+
- Class: 48
25+
Script: {instanceID: 0}
26+
- Class: 89
27+
Script: {instanceID: 0}
28+
- Class: 104
29+
Script: {instanceID: 0}
30+
- Class: 157
31+
Script: {instanceID: 0}
32+
- Class: 196
33+
Script: {instanceID: 0}
34+
- Class: 212
35+
Script: {instanceID: 0}
36+
- Class: 213
37+
Script: {instanceID: 0}
38+
SerializeReferenceClassIdentifiers: []
39+
Assets:
40+
- Assets/Scenes/Scene1.unity
41+
- Assets/Scenes/Scene2.unity
42+
Dependencies: []
Binary file not shown.

0 commit comments

Comments
 (0)