Open-Source Wikis

/

Bevy

/

Packages

/

bevy_scene

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:

  • Scene asset — a deserialized scene ready to spawn.
  • DynamicScene asset — a more flexible variant that can carry partial component sets.
  • SceneRoot component — drop this onto an entity with a Handle<Scene> and the scene gets spawned beneath it.
  • SceneSpawner resource — 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.rs

Key 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.rs for the SceneSpawner API; the systems in lib.rs for the change-driven path.
  • Component allow/deny lists: SceneFilter.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

bevy_scene – Bevy wiki | Factory