Runtime Streaming Systems
ProStream runtime streaming uses DOTS systems plus managed helpers to load and unload scene content based on distance from a loading trigger. The architecture (Runtime Streaming v2) combines a managed initialization gate, ECS setup systems, and dynamic execution systems.
Overview
At runtime, ProStream supports two streaming paths:
- Entity SubScene streaming (ECS section load/unload using
RequestSceneLoaded) - GameObject SubScene streaming (managed
GameObjectSceneStreamingManager+ ECS systems)
Streaming only works after editor preparation is complete:
- Scene setup
- Search filters and enabled rules
- Calculate Positions (Generates Spatial Data)
- Create SubScenes
If SubScenes were not created, there is nothing to stream.
Key Runtime Components
- StreamingManager:
StreamingManageris the scene bridge holding trigger and layer references plus runtime toggles. - StreamingSystemsInitializer:
StreamingSystemsInitializeris a managed initialization gate (SystemBase) that validates prerequisites, initializesStreamingSystemsManager, and pushes runtime state into ECS config (StreamingSystemsConfig) every frame. - SubSceneStreamingSetupSystem: An ECS setup system (
SystemBase) that initializes required entities, components, and dynamic buffers (LayerLoadingRanges). - SubSceneLoadingSystem:
SubSceneLoadingSystemis anISystemthat schedulesSubSceneLoadingJobto addRequestSceneLoadedbased on player position and layer ranges. - SubSceneUnloadingSystem:
SubSceneUnloadingSystemis anISystemthat schedulesSubSceneUnloadingJobto removeRequestSceneLoadedusing the same prerequisites plus unload controls. - LoadingDistanceSystem:
LoadingDistanceSystemprovides APIs for live, runtime-adjustable layer ranges (e.g.,SetGlobal).
System Gating (Important)
Entity streaming systems require setup singletons/components to exist before they run:
UseStreamingSystemsStreamingSystemsConfig(Updated every frame by the Initializer)StreamingSetupCompleteLayerLoadingRanges
If these are missing, loading/unloading systems will not update.
Distance Model
For Entity SubScenes, ProStream uses section bounds (AABB) and computes distance from trigger position to the closest point on the bounds.
Loading check
SubSceneLoadingJob loads when distance is inside the configured range:
distance >= loadingStartDistancedistance < loadingEndDistance
Sections marked persistent are always loaded.
Unloading check
SubSceneUnloadingJob unloads when outside the end range with a multiplier buffer:
adjustedEndDistance = loadingEndDistance * UnloadBufferMultiplier
Current initializer value is 1.05f.
Runtime-Adjustable Layer Ranges
Loading ranges can be modified at runtime using the LoadingDistanceSystem. This allows for dynamic streaming adjustments based on gameplay events. For example, updating a specific layer's range:
// Example: Updating the range for a specific section index at runtime
LoadingDistanceSystem.SetGlobal(sectionIndex, new float2(newStartDistance, newEndDistance));StreamingManager (User-facing)
StreamingManager is created automatically during the SubScene creation workflow (Cleanup phase) and provides:- Loading trigger reference
- Section collection (
LayerData) - Runtime toggles for entity and GO streaming
Exposed toggles include:
enableEntitySubScenes,enableLoading,enableUnloadingenableGOSubScenes,enableGOLoading,enableGOUnloading
Inspector fields include:
- Loading Trigger
- Section Collection (
LayerData) - Streaming status labels
Runtime Lifecycle
High-level play mode flow (Runtime v2):
- Scene Readiness: Scene becomes runtime-ready.
- Initialization:
StreamingSystemsInitializerpasses prerequisites and initializesStreamingSystemsManager. - Config Update: The ECS config entity (
StreamingSystemsConfig) is updated each frame. - ECS Setup:
SubSceneStreamingSetupSysteminitializes setup entities and buffers (LayerLoadingRanges). - Execution:
SubSceneLoadingSystemschedules distance-based loading jobs, followed bySubSceneUnloadingSystem. - Live Updates (Optional): At runtime,
LoadingDistanceSystem.Set/SetGlobalupdates layer ranges, which the load/unload jobs will observe on subsequent updates.
Troubleshooting Quick Checks
If sections do not stream:
- Verify SubScenes were created successfully.
- Verify
StreamingManagerexists and has Trigger + LayerData. - Verify scene progress reached
StreamingReady. - Verify layer loading ranges are set for your scene scale.
- Check Console for streaming setup/system warnings.
If loading/unloading feels unstable near boundaries:
- Increase layer end distance.
- Account for unload buffer multiplier behavior.
If GO SubScenes work in editor but not build:
- Check that GO SubScene scenes are included in Build Settings.
See Also
- Streaming Layers - Configure distance ranges
- SubScene Creation - Build SubScenes used at runtime
- Standard Workflow - End-to-end setup flow
- Troubleshooting - Common runtime issues
