bevy-assets
Skill16 starsChanged 3 months agoMITView on GitHub
Use when loading with `AssetServer`, holding `Handle<T>`, spawning Bevy 0.19 glTF `WorldAsset` scenes, reading `Assets<T>`, enabling hot reload, configuring `AssetServer::load_builder`, resolving `AssetPath`, or implementing a `Reader::seekable` backend.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-audioSkill
- bevy-camerasSkill
- bevy-captureSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-diagnostics-profilingSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-fluentSkill
- bevy-input-actionsSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 104
Advanced loads use builders in 0.19: Prefer AssetServer::load_builder() for settings, guards, untyped loads, or approval overrides.
- Very specific: line 105
AssetPath::resolvenow takes&AssetPath: Use resolve_str/resolve_embed_str when the child path starts as text. - Very specific: line 110
Hot reload is dev-only: Don't ship watch_for_changes_override: Some(true) in a release build — it polls the filesystem.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bevy 0.19 — Assets
When to use this skill
- Loading a model, texture, audio file, or scene.
- Reading the loaded data back from
Assets<T>once it's ready. - Reacting to load progress (
AssetEvent::Added/Modified). - Spawning glTF scenes, waiting for
WorldInstanceReady, reading names/extras, or owning/despawning an instance cleanly. - Enabling hot-reload during development.
- Writing your own loader → see
bevy-custom-assets.
Canonical pattern
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(AssetPlugin {
// Hot-reload on file change — dev-only.
watch_for_changes_override: Some(true),
..default()
}))
.init_resource::<MyHandles>()
.add_systems(Startup, load_handles)
.add_systems(Update, react_to_loads)
.run();
}
#[derive(Resource, Default)]
struct MyHandles {
hero: Handle<WorldAsset>,
bricks: Handle<Image>,
}
fn load_handles(asset_server: Res<AssetServer>, mut handles: ResMut<MyHandles>) {
// GLTF scenes are addressed by sub-asset label.
handles.hero = asset_server.load("models/hero.glb#Scene0");
handles.bricks = asset_server.load("textures/bricks.png");
}
fn react_to_loads(
mut ev: MessageReader<AssetEvent<Image>>,
images: Res<Assets<Image>>,
) {
for event in ev.read() {
if let AssetEvent::LoadedWithDependencies { id } = event {
if let Some(img) = images.get(*id) {
info!("image loaded: {}x{}", img.width(), img.height());
}
}
}
}Asset paths
use bevy::asset::AssetPath;
// `LoadContext::path()` returns `AssetPath`, not `&Path`.
// Build paths explicitly when generating handles inside a custom loader:
let path = AssetPath::from("textures/bricks.png");
let path_with_label = AssetPath::from("models/hero.glb").with_label("Scene0");
let _ = path;
let _ = path_with_label;Asset readiness check
use bevy::prelude::*;
# fn _check(
asset_server: Res<AssetServer>,
handles: Res<MyHandles>,
# ) {
use bevy::asset::LoadState;
if asset_server.load_state(&handles.hero) == LoadState::Loaded {
// Safe to spawn WorldAssetRoot(handles.hero.clone()).
}
# }
# #[derive(Resource)] struct MyHandles { hero: Handle<WorldAsset> }Bevy 0.19 gotchas
LoadContext::path()returnsAssetPath, not&Path. Callers that didctx.path().to_string_lossy()need toctx.path().path().to_string_lossy()or use theAssetPathAPI directly.SeekableReaderis new in 0.18. Loaders that need random access into the underlying file can ask:if let Ok(s) = reader.seekable() { /* s: &mut dyn SeekableReader */ }.- Every custom
Readerimplementsseekable()in 0.19. ReturnOk(self)when it also implementsAsyncSeek; otherwise returnErr(ReaderNotSeekableError).AsyncSeekForwardwas removed. - Advanced loads use builders in 0.19. Prefer
AssetServer::load_builder()for settings, guards, untyped loads, or approval overrides; the many specializedload_*variants are deprecated. AssetPath::resolvenow takes&AssetPath. Useresolve_str/resolve_embed_strwhen the child path starts as text.AssetSourceBuilder::new(...)replacesAssetSource::build().with_reader(...). Existing custom asset sources need to be re-shaped.AssetSourcechannel isasync_channel::Senderin 0.18 (wascrossbeam_channel). Usesend_blocking(...).Image::reinterpret_size(size)returnsResultin 0.18.- Sub-asset labels.
path.glb#Scene0,path.glb#Mesh0/Primitive0— distinct handles, can be loaded independently. Forgetting the label gives you the root asset, not the named one. - Hot reload is dev-only. Don't ship
watch_for_changes_override: Some(true)in a release build — it polls the filesystem. asset_server.load(...)is non-blocking. QueryingAssets<T>::getimmediately after returnsNone. Wait forAssetEvent::LoadedWithDependenciesor pollload_state(...).AssetEvent<T>is aMessage, so iterate withMessageReader<AssetEvent<T>>, not the oldEventReader.
See also
- glTF scenes —
GltfAssetLabel,WorldAssetRoot, instance readiness/ownership, names/extras, metadata proxies, and despawning. bevy-custom-assets— writing anAssetLoaderand nested load builder.bevy-save-load— durable stable IDs and save schema; glTF names/entity IDs are not persistence contracts.bevy-migration-0-17-to-0-18—LoadContext::pathand channel-type renames.bevy-migration-0-18-to-0-19— load builders and requiredReader::seekable.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

