bevyengine/bevy
bevy_scene
The runtime side of scenes. A scene is a serialized snapshot of a World (entities + components) — bevy_scene knows how to spawn one, instantiate child hierarchies, and bridge Handle<Scene> to live entities. The serialization format itself lives in bevy_world_serialization.
Purpose
Scenes are how levels, prefabs, and saved games persist. The crate provides:
Sceneasset — a deserialized scene ready to spawn.DynamicSceneasset — a more flexible variant that can carry partial component sets.SceneRootcomponent — drop this onto an entity with aHandle<Scene>and the scene gets spawned beneath it.SceneSpawnerresource — programmatic spawn / despawn by handle.
Directory layout
crates/bevy_scene/src/
├── lib.rs # ScenePlugin
├── scene.rs # Scene asset
├── dynamic_scene.rs # DynamicScene asset
├── scene_filter.rs # Filter for which components serialize
├── scene_loader.rs # Loads .scn / .scn.ron from disk
├── scene_spawner.rs # SceneSpawner resource + commands
└── prelude.rsKey abstractions
| Type | File | Description |
|---|---|---|
Scene |
crates/bevy_scene/src/scene.rs |
Asset; a World-like snapshot. |
DynamicScene |
crates/bevy_scene/src/dynamic_scene.rs |
Asset with looser typing. Supports merging into an existing world. |
SceneRoot |
crates/bevy_scene/src/scene.rs |
Component: (Handle<Scene>). Spawns the scene as children. |
DynamicSceneRoot |
crates/bevy_scene/src/dynamic_scene.rs |
Same, for DynamicScene. |
SceneSpawner |
crates/bevy_scene/src/scene_spawner.rs |
Resource: spawn/despawn scenes manually. |
SceneFilter |
crates/bevy_scene/src/scene_filter.rs |
Allow/deny lists for which components to serialize. |
How it works
SceneRoot (or DynamicSceneRoot) is a marker component with a handle. A system in SpawnScene sees newly added roots, resolves the handle to a Scene, and spawns the entities into the world as children of the root. Subsequent loads (e.g. hot-reloaded scenes) re-spawn into a fresh sub-tree under the same root.
bevy_scene itself does not parse RON or BSN — it consumes already-deserialized assets produced by bevy_world_serialization.
Integration points
- Depends on:
bevy_app,bevy_ecs,bevy_asset,bevy_reflect,bevy_world_serialization,bevy_transform. - Depended on by:
bevy_gltf(a glTF imports as a scene),DefaultPlugins.
Entry points for modification
- Custom scene format: more naturally lives in
bevy_world_serialization, not here. - Spawn lifecycle hooks:
scene_spawner.rsfor theSceneSpawnerAPI; the systems inlib.rsfor the change-driven path. - Component allow/deny lists:
SceneFilter.
See also
bevy_world_serialization— the format.bevy_gltf— the most common scene producer.- Scenes feature page.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.