diff --git a/examples/shader/shader_material_wesl.rs b/examples/shader/shader_material_wesl.rs index a436d0a49e..9261596f2d 100644 --- a/examples/shader/shader_material_wesl.rs +++ b/examples/shader/shader_material_wesl.rs @@ -1,7 +1,6 @@ //! A shader that uses the WESL shading language. use bevy::{ - asset::{load_internal_asset, weak_handle}, pbr::{MaterialPipeline, MaterialPipelineKey}, prelude::*, reflect::TypePath, @@ -16,8 +15,6 @@ use bevy::{ /// This example uses shader source files from the assets subdirectory const FRAGMENT_SHADER_ASSET_PATH: &str = "shaders/custom_material.wesl"; -/// An example utility shader that is used by the custom material -pub const UTIL_SHADER_HANDLE: Handle = weak_handle!("748706a1-969e-43d4-be36-74559bd31d23"); fn main() { App::new() @@ -34,14 +31,21 @@ fn main() { /// A plugin that loads the custom material shader pub struct CustomMaterialPlugin; +/// An example utility shader that is used by the custom material +#[expect( + dead_code, + reason = "used to kept a strong handle, shader is referenced by the material" +)] +#[derive(Resource)] +struct UtilityShader(Handle); + impl Plugin for CustomMaterialPlugin { fn build(&self, app: &mut App) { - load_internal_asset!( - app, - UTIL_SHADER_HANDLE, - "../../assets/shaders/util.wesl", - Shader::from_wesl - ); + let handle = app + .world_mut() + .resource_mut::() + .load::("shaders/util.wesl"); + app.insert_resource(UtilityShader(handle)); } }