diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 096c3f6315d1b..260051d05098a 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -1,5 +1,5 @@ use bevy_asset::{Asset, Handle}; -use bevy_reflect::TypePath; +use bevy_reflect::{impl_type_path, Reflect}; use bevy_render::{ mesh::MeshVertexBufferLayout, render_asset::RenderAssets, @@ -97,12 +97,17 @@ pub trait MaterialExtension: Asset + AsBindGroup + Clone + Sized { /// When used with `StandardMaterial` as the base, all the standard material fields are /// present, so the `pbr_fragment` shader functions can be called from the extension shader (see /// the `extended_material` example). -#[derive(Asset, Clone, TypePath)] +#[derive(Asset, Clone, Reflect)] +#[reflect(type_path = false)] pub struct ExtendedMaterial { pub base: B, pub extension: E, } +// We don't use the `TypePath` derive here due to a bug where `#[reflect(type_path = false)]` +// causes the `TypePath` derive to not generate an implementation. +impl_type_path!((in bevy_pbr::extended_material) ExtendedMaterial); + impl AsBindGroup for ExtendedMaterial { type Data = (::Data, ::Data); diff --git a/examples/shader/extended_material.rs b/examples/shader/extended_material.rs index 704537423708a..7f055a9bef860 100644 --- a/examples/shader/extended_material.rs +++ b/examples/shader/extended_material.rs @@ -1,6 +1,5 @@ //! Demonstrates using a custom extension to the `StandardMaterial` to modify the results of the builtin pbr shader. -use bevy::reflect::TypePath; use bevy::{ pbr::{ExtendedMaterial, MaterialExtension, OpaqueRendererMethod}, prelude::*, @@ -73,7 +72,7 @@ fn rotate_things(mut q: Query<&mut Transform, With>, time: Res