Skills

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
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: AssetServer is the resource that loads from disk. AssetServer::load returns a Handle and does not reload while a strong handle still exists. Loaded data lives in Assets<T>. AssetServer::is_loaded_with_dependencies is true when the asset and its dependencies are ready. LoadState is 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::add inserts a procedural asset and does not deduplicate.
  • Hot reload: the file_watcher Cargo feature, and AssetPlugin's watch_for_changes_override field, are the toggles named on the asset index.
  • Scenes: bevy::scene describes a Scene (entity, components, children, assets), built with the bsn! macro. World::spawn_scene and Commands::spawn_scene spawn immediately and error if asset dependencies are not loaded. World::queue_spawn_scene and Commands::queue_spawn_scene wait, then spawn in the SpawnScene schedule between Update and PostUpdate.
  • Hierarchy in a scene: Children [ ... ] inside bsn!. Separate sibling entities with --. #Name assigns a Name inside that macro's scope.

Asset choice

NeedDo this
Load a fileAssetServer::load returns a Handle
Wait until readyis_loaded_with_dependencies before a state change
Spawn a scene nowspawn_scene only after dependencies are loaded
Spawn when readyqueue_spawn_scene (SpawnScene sits between Update and PostUpdate)
Children in that sceneChildren inside bsn!
Change one entity's meshSwap the Handle on the component that stores it
Read the whole SKILL.md on GitHub

More in Engineering