Scenes and reflection
Compose entities with bsn! scenes, save and load worlds as files, and inspect and change Rust values at runtime with reflection.
On this page
A game rarely spawns entities one at a time. A level is walls, props and enemies; a button is a node with text inside. The engine gives you three related tools for working with groups of entities and their data:
| Tool | What it's for | Crate |
|---|---|---|
bsn! scenes | Describing an entity, its components and its children once in code, and spawning it wherever you need it, with field-level overrides. | neo::scene |
| World assets and dynamic worlds | Entities and resources as data: glTF scenes, .scn.ron files, and saving part of a running world to a file and loading it back. | neo::world_serialization |
| Reflection | Reading and changing Rust values by field name at runtime, and the type registry that makes serialization and dynamic worlds work. | neo::reflect |
All three are on in NEO's builds.
Pages in this section#
| Page | What it covers |
|---|---|
| Reflection | #[derive(Reflect)], reading and setting fields by name, paths, dynamic types and patches. |
| The type registry | AppTypeRegistry, automatic registration, type data such as ReflectComponent, and reflected traits. |
| Serialization | Turning reflected values into RON or JSON and back, without serde derives. |
| Dynamic worlds and scene files | DynamicWorld, WorldAsset, .scn.ron files, spawning them and saving a world. |
| Scenes with bsn! | The bsn! macro: composition, patching, children, named references, observers and asset paths. |
Which one to use#
- To build the same kind of object many times from code (an enemy, a UI panel), write a function that returns a
bsn!scene. - To load a model or a level made in a tool, load its glTF scene or
.scn.ronfile as a world asset. - To save game state or an edited level, extract a
DynamicWorldand serialize it. - To write tools that work with any component (inspectors, editors, scripting bridges), use reflection.