bevyengine/bevy
bevy_world_serialization
The format layer for scenes and prefabs. Defines BSN (Bevy Scene Notation), reflection-driven RON serialization, and the type registry plumbing scenes need.
Purpose
Carved out of bevy_scene so the format itself can evolve independently of the runtime spawning logic. This crate provides:
- BSN — Bevy's bespoke human-readable scene format.
- Reflection-driven RON for round-tripping
Worlds. - Asset support for
.bsnfiles. - Scene merging semantics (DynamicScene-style).
Directory layout
crates/bevy_world_serialization/src/
├── lib.rs
├── bsn/ # BSN parser + AST
├── world_serialize.rs # Serialize a World to RON via reflection
├── world_deserialize.rs
└── …Key abstractions
| Type | File | Description |
|---|---|---|
BsnAsset |
crates/bevy_world_serialization/src/bsn/ |
Parsed BSN file. |
Scene (re-exposed) |
crates/bevy_world_serialization/src/lib.rs |
A World snapshot ready for spawning. |
Loader for .bsn / .scn.ron |
crates/bevy_world_serialization/src/lib.rs |
Asset loaders. |
How it works
BSN
BSN is a structured scene format inspired by RON but specialized for component composition. It supports nested entities, component tuples, asset references, and reflectable expressions for component values. The parser is in bsn/.
Reflection-driven RON
Existing .scn.ron scenes use bevy_reflect's serde codec to encode each component's reflected value. The implementation walks every entity in the source World and produces a stable RON representation. Loading is the inverse: parse RON → look up types by name in the TypeRegistry → reconstruct components → spawn entities.
Integration points
- Depends on:
bevy_app,bevy_ecs,bevy_asset,bevy_reflect,serde,ron. - Depended on by:
bevy_scene(the runtime side),bevy_gltf(which produces a scene from glTF),bevy_remote(the BRP serializes via the same reflection path).
Entry points for modification
- BSN syntax changes:
bsn/parse.rsplus the AST modules. - RON format tweaks:
world_serialize.rs/world_deserialize.rs. The format is reflection-driven so additions to types automatically flow through. - Custom asset reference syntax:
bsn/.
See also
bevy_scene— the consumer that spawns scenes.bevy_reflect— drives the codec.- Scenes feature page.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.