# 1. Streaming Mental Model and World Layout Part of [[Open-World Streaming]]. Next: [[2. WorldGrid Cells and Hysteresis]]. ## 1.1 Three kinds of content | Lives in | What | Lifetime | |---|---|---| | **Bootstrap scene** (`World_Bootstrap`) | Player, camera rig, `CellStreamer`, `FloatingOrigin`, UI, audio listener, global managers, directional light, low-detail **world stand-in** (far terrain, skyline landmarks) | Whole session | | **Cell scenes** (`World_3_-2`) | Ground, props, buildings, local lights, NavMesh surface, spawners, triggers for this square of the world | Loaded near the player, unloaded behind | | **Data** (ScriptableObjects, save file) | What happened in a cell: chests opened, NPCs killed | Outlives cells. A cell *reads* it on load | The last row is the one people forget. If a chest's "opened" flag lives on the chest's MonoBehaviour, it resets every time the cell reloads. Keep that state in a registry outside the cell (see [[High Scores, Saves and Player Stats]] and [[ScriptableObject Architecture]]). When the cell loads, it asks the registry. ## 1.2 The grid - Square cells on X/Z, `cellSize` metres wide (256 m in this series). Cell `(x, z)` covers `[x·size, (x+1)·size)`. - Scene names follow the convention `World_{x}_{z}`, for example `World_0_0` and `World_-1_2`. The name *is* the coordinate, so the streamer needs no lookup table. - **Author every cell at its true world position.** `World_2_0`'s content sits between x = 512 and x = 768. Open several cell scenes together in the Editor (drag them into the Hierarchy) and they line up. ## 1.3 Two radii ```text unload radius 2 ─────────────────┐ load radius 1 ───────┐ │ . . . . . │ │ . L L L . L = loaded (wanted) . L P L . P = player's cell . L L L . . = kept if already loaded, never newly loaded . . . . . ``` - **Load radius:** cells within this Chebyshev distance (a square ring) are wanted. - **Unload radius:** cells *farther* than this are released. It's bigger than the load radius on purpose. That gap is **hysteresis**: walking back and forth over a cell border doesn't load and unload the same scene every few seconds. ## 1.4 Budgets Loading is never free. The main thread still integrates each scene: it runs `Awake`/`OnEnable` on every object, registers renderers and builds physics. So the streamer has two knobs: - `maxConcurrentLoads`: how many cell loads can be in flight. 1–2 is typical. More doesn't load faster from one disk and makes each one finish later. - `maxStartsPerFrame`: how many loads may *start* per frame. 1 spreads the cost. And one rule: **the load radius must cover the distance the player can travel during a worst-case load.** If a cell takes 2 s to load on target hardware and the player sprints at 10 m/s, they cover 20 m. A 256 m cell with radius 1 gives at least 256 m of warning, which is plenty. A 32 m cell with radius 1 would not be enough. Measure the load time on the slowest device, not the Editor. ## 1.5 Build it 1. Create a folder `Assets/World/`. Create the scene `World_Bootstrap`. Add your player, a camera, and a large flat **far stand-in** plane at y = −0.1 so there's always something underfoot. 2. Create 9 scenes, `World_-1_-1` … `World_1_1`. In each, add a 256 × 256 plane (scale 25.6) placed at the cell's centre, `(x·256 + 128, 0, z·256 + 128)`. Give each a different colour and one tall, distinctive prop so you can see which cell is which. 3. Open **File → Build Profiles**. Add `World_Bootstrap` first, then every cell scene. (Part 4 replaces this step with Addressables.) 4. Keep only `World_Bootstrap` open, and press Play once you've added the streamer in part 3. The bootstrap scene is the only one in the scene list that's loaded with `LoadSceneMode.Single`. Everything else is additive. That matches the pattern in [[SceneManagement in Unity 6]].