
Bevy Asset Scenes
Load Bevy 0.20 assets with AssetServer and spawn scenes with bsn!, spawn_scene, and...
Install
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-asset-scenes -g -a claude-code -y- Repository
- thedivergentai/Game-Dev-Agentic-Skills917
- Category
- Engineering
- Updated
- 19d ago
- License
- LGPL-3.0
- Context cost
- Mediumabout 2,108 tokens
- Runs scripts
- No, instructions only
What it does
Load Bevy 0.20 assets with AssetServer and spawn scenes with bsn!, spawn_scene, and queue_spawn_scene. Use when content comes from disk, a handle must be ready, or a level root should be replaced. Keywords: AssetServer, Handle, is_loaded_with_dependencies, bsn, Scene, file_watcher, LevelRoot.
Bevy asset scenes
When to use
Load this when content comes from disk or a scene description should spawn entities. AssetServer loads files. bsn! describes a Scene that spawn_scene or queue_spawn_scene turns into entities.
ECS shape
- Assets:
AssetServeris the resource that loads from disk.AssetServer::loadreturns aHandleand does not reload while a strong handle still exists. Loaded data lives inAssets<T>.AssetServer::is_loaded_with_dependenciesis true when the asset and its dependencies are ready.LoadStateis the status type named on that page. - Handles: strong handles are reference counted. Dropping the last strong handle removes the asset. Weak handles do not keep it alive.
Assets::addinserts a procedural asset and does not deduplicate. - Hot reload: the
file_watcherCargo feature, andAssetPlugin'swatch_for_changes_overridefield, are the toggles named on the asset index. - Scenes:
bevy::scenedescribes aScene(entity, components, children, assets), built with thebsn!macro.World::spawn_sceneandCommands::spawn_scenespawn immediately and error if asset dependencies are not loaded.World::queue_spawn_sceneandCommands::queue_spawn_scenewait, then spawn in theSpawnSceneschedule betweenUpdateandPostUpdate. - Hierarchy in a scene:
Children [ ... ]insidebsn!. Separate sibling entities with--.#Nameassigns aNameinside that macro's scope.
Asset choice
| Need | Do this |
|---|---|
| Load a file | AssetServer::load returns a Handle |
| Wait until ready | is_loaded_with_dependencies before a state change |
| Spawn a scene now | spawn_scene only after dependencies are loaded |
| Spawn when ready | queue_spawn_scene (SpawnScene sits between Update and PostUpdate) |
| Children in that scene | Children inside bsn! |
| Change one entity's mesh | Swap the Handle on the component that stores it |
