/bevy-skills:bevy-assetsfrom bevy-skills
Guides loading, handling, and reacting to assets in Bevy 0.20: AssetServer, Handle<T>, Assets<T>, LoadState, AssetPath, and WorldAsset for glTF scenes.
Ships in bevy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Assets<T> once it is ready.AssetEvent::Added / LoadedWithDependencies).bevy-custom-assets.use bevy::asset::AssetPath;
use bevy::image::ImageLoaderSettings;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(AssetPlugin {
// Hot-reload on file change. Dev-only; needs the `file_watcher` feature.
watch_for_changes_override: Some(true),
..default()
}))
.init_resource::<MyHandles>()
.add_systems(Startup, load_handles)
.add_systems(Update, (react_to_loads, check_ready, tint_material))
.run();
}
#[derive(Resource, Default)]
struct MyHandles {
hero: Handle<WorldAsset>,
bricks: Handle<Image>,
normal_map: Handle<Image>,
ground: Handle<StandardMaterial>,
}
fn load_handles(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut handles: ResMut<MyHandles>,
) {
// glTF scenes are addressed by sub-asset label. 0.19+: `Scene` -> `WorldAsset`.
handles.hero = asset_server.load("models/hero.glb#Scene0");
commands.spawn(WorldAssetRoot(handles.hero.clone())); // was `SceneRoot` in 0.18
handles.bricks = asset_server.load("textures/bricks.png");
// 0.19+: advanced loads go through one builder. Replaces `load_with_settings`,
// `load_acquire`, `load_untyped`, ... (deleted in 0.20).
handles.normal_map = asset_server
.load_builder()
.with_settings(|s: &mut ImageLoaderSettings| s.is_srgb = false)
.load("textures/bricks_normal.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());
}
}
}
}
fn check_ready(asset_server: Res<AssetServer>, handles: Res<MyHandles>) {
// `LoadState` has no `PartialEq` (`Failed` carries an `Arc<AssetLoadError>`): use the predicates.
if asset_server.load_state(&handles.hero).is_loaded() {
// Safe to read Assets<WorldAsset> now.
}
}
fn tint_material(handles: Res<MyHandles>, mut materials: ResMut<Assets<StandardMaterial>>) {
// 0.19+: `get_mut` returns `AssetMut`, which emits `AssetEvent::Modified`
// only on `DerefMut`. Compare first to avoid a GPU re-upload every frame.
let Some(mut mat) = materials.get_mut(&handles.ground) else {
return;
};
if mat.base_color != Color::WHITE {
mat.base_color = Color::WHITE;
}
}
use bevy::asset::AssetPath;
let base = AssetPath::from("models/hero.glb");
let labeled = base.clone().with_label("Scene0");
// 0.19+: `resolve` / `resolve_embed` take `&AssetPath`; the `&str`
// forms are `resolve_str` / `resolve_embed_str` and return `Result`.
let sibling = base.resolve(&AssetPath::from("hero_lod1.glb"));
let sibling_str = base.resolve_str("hero_lod1.glb");
// 0.19+: `Option<&str>`, was `Option<String>`.
let ext: Option<&str> = labeled.get_full_extension();
#[derive(Resource, Default)]
struct CurrentSkybox(Option<AssetId<Image>>); // 0.20: not `AssetId::invalid()`
fn read_skybox(current: Res<CurrentSkybox>, images: Res<Assets<Image>>) {
let Some(id) = current.0 else { return };
if let Some(img) = images.get(id) {
// 0.19+: `pixel_bytes` returns `Result<_, TextureAccessError>`, was `Option`.
let _ = img.pixel_bytes(UVec3::ZERO);
}
}
AssetId::invalid() and AssetId::INVALID_UUID are deprecated. Store Option<AssetId<T>> and use None. AssetId::default() is not a null value; a real asset can own it.AssetServer load variants are gone. load_with_settings, load_acquire, load_untyped, load_*_override were deprecated in 0.19 and deleted in 0.20. Only load and load_builder() remain. Builder methods: with_settings, with_guard, override_unapproved, then load / load_erased(type_id, path) / load_untyped.AssetLoadError::RequestedHandleTypeMismatch(Box<RequestedHandleTypeMismatchError>) and LoadDirectError::LoadError { error: Box<AssetLoadError>, .. }. Exhaustive matches need */Box::new.UntypedHandle::meta_transform() is deleted. There is no replacement.compressed_image_saver now means BCn/ASTC via ctt; the old Basis Universal path is compressed_image_saver_universal (use it for web). The default processor now compresses JPEG as well as PNG; restrict with ImagePlugin { default_compressed_image_processor_extensions: ["png".into()].into(), .. }.bevy_scene is bevy_world_serialization. Scene → WorldAsset, SceneRoot → WorldAssetRoot, SceneInstanceReady → WorldInstanceReady, SceneSpawner → WorldInstanceSpawner, DynamicScene → DynamicWorld. Paths: bevy::world_serialization::*; the prelude re-exports them. bevy::scene is now BSN. Cargo: the scene feature enables both.Assets::get_mut returns AssetMut, not &mut A. Bind it mut. AssetEvent::Modified fires only when you actually DerefMut; get_mut_untracked gives the old &mut A.AssetPath::resolve / resolve_embed take &AssetPath. String input: resolve_str / resolve_embed_str (fallible).AssetPath::get_full_extension returns Option<&str>. Add .map(ToString::to_string) if you stored it.Image::pixel_bytes / pixel_bytes_mut / pixel_data_offset return Result<_, TextureAccessError> (OutOfBounds, UnsupportedTextureFormat, Uninitialized).AssetSaver::save takes SavedAsset<'_, '_, A> and an extra asset_path: AssetPath<'_>.Resource is now a Component. #[derive(Resource)] still works for handle holders; see bevy-ecs-components for query conflicts.path.glb#Scene0, path.glb#Mesh0/Primitive0 are distinct handles. No label = the root asset.asset_server.load(...) is non-blocking. Assets<T>::get right after returns None. Wait for LoadedWithDependencies or poll load_state(..).is_loaded().LoadState is not PartialEq. Stale snippets write == LoadState::Loaded; use is_loaded() / is_failed() or matches!.file_watcher Cargo feature; watch_for_changes_override: Some(true) polls the filesystem.AssetEvent<T> is a Message: MessageReader<AssetEvent<T>>, not EventReader.LoadContext::path() returns &AssetPath, not &Path; .path() again for the OS path.bevy-custom-assets — AssetLoader, LoadContext::load_builder, Reader::seekable.bevy-cargo-features — file_watcher, compressed_image_saver*, scene, http/https sources.bevy-migration-0-19-to-0-20 and bevy-migration-0-18-to-0-19 — full rename tables.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub chrisgliddon/bevy-skills --plugin bevy-skills32 skills in this plugin
/bevyUse when starting any Bevy task, choosing between Update and FixedUpdate, picking Cargo feature flags, or recalling which sibling skill covers ECS, assets, rendering, UI, or migration. Routes to the right Bevy 0.20 skill and pins the engine version for downstream snippets./bevy-a11yUse when designing or auditing high-standard video-game accessibility in Bevy 0.20, integrating screen readers and focus navigation, supporting adaptive controllers and complete remapping, implementing captions or audio description, checking contrast and motion safety, or building disabled-player test evidence./bevy-animationUse when wiring `AnimationPlayer` + `AnimationGraphHandle`, building an `AnimationGraph` from glTF clips, blending state-driven animations with `AnimationTransitions::play`, isolating body parts with `AnimationMask`, firing gameplay sync via `#[derive(AnimationEvent)]` + `On<E>` observers, tweening with `AnimatableCurve` / `EaseFunction` / `CubicSegment::new_bezier_easing` from `bevy::curve`, or applying the 12 Basic Principles of Animation to 3D characters in Bevy 0.20./bevy-audioUse when implementing audio in Bevy 0.20 with `AudioPlayer`, `PlaybackSettings`, `AudioSink` or `SpatialAudioSink`, spatial listeners, application mix groups, ambience/music transitions, asset lifetime, browser gesture restrictions, or choosing built-in audio versus `bevy_seedling 0.8`./bevy-camerasUse when spawning `Camera3d` or `Camera2d`, choosing a `Projection`, rendering to an image with the `RenderTarget` component, adding `Hdr` / `Tonemapping::Linear` / `ScreenSpaceTransmission` to a camera, wiring `FreeCamera`, `PanCamera` or the new `PanOrbitCamera` from `bevy::camera_controller`, ordering views with `Camera::order`, or setting a per-camera `AmbientLight` in Bevy 0.20./bevy-captureUse when adding `CapturePlugin` to record a `Camera3d` or `Camera2d` to video, spawning `CaptureBundle` with `RenderTarget::target_headless`, calling `Capture::start` with `Mp4Openh264Encoder`, `Mp4FfmpegCliEncoder`, `Mp4FfmpegCliPipeEncoder`, `GifEncoder` or `FramesEncoder`, pausing with `Capture::pause`, or hitting "failed to select a version for bevy_capture" because the crate still pins Bevy 0.19 while your app is on Bevy 0.20.Other plugins' skills for the same job