Fix fighter material not removing the original material. #92
@@ -1,10 +1,17 @@
|
|||||||
use bevy::{gltf::GltfMaterialName, pbr::{ExtendedMaterial, MaterialExtension}, prelude::*, render::render_resource::AsBindGroup, shader::ShaderRef, world_serialization::WorldInstanceReady};
|
use bevy::{
|
||||||
|
gltf::GltfMaterialName,
|
||||||
|
pbr::{ExtendedMaterial, MaterialExtension},
|
||||||
|
prelude::*,
|
||||||
|
render::render_resource::AsBindGroup,
|
||||||
|
shader::ShaderRef,
|
||||||
|
world_serialization::WorldInstanceReady,
|
||||||
|
};
|
||||||
|
|
||||||
pub type FighterMaterial = ExtendedMaterial<StandardMaterial, FighterMaterialExtension>;
|
pub type FighterMaterial = ExtendedMaterial<StandardMaterial, FighterMaterialExtension>;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FighterMesh {
|
pub struct FighterMesh {
|
||||||
pub fighter: Entity
|
pub fighter: Entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone, Default)]
|
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone, Default)]
|
||||||
@@ -64,12 +71,22 @@ pub fn bind_fighter_material(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.entity(entity).insert((MeshMaterial3d(asset_materials.add(ExtendedMaterial {
|
commands
|
||||||
base: StandardMaterial {
|
.entity(entity)
|
||||||
// can be used in forward or deferred mode
|
.remove::<MeshMaterial3d<StandardMaterial>>()
|
||||||
..original_material.clone()
|
.insert((
|
||||||
},
|
MeshMaterial3d(asset_materials.add(ExtendedMaterial {
|
||||||
extension: FighterMaterialExtension::new(bevy::color::palettes::css::BLUE.into())
|
base: StandardMaterial {
|
||||||
})), FighterMesh { fighter: scene_ready.entity }));
|
// can be used in forward or deferred mode
|
||||||
|
..original_material.clone()
|
||||||
|
},
|
||||||
|
extension: FighterMaterialExtension::new(
|
||||||
|
bevy::color::palettes::css::BLUE.into(),
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
FighterMesh {
|
||||||
|
fighter: scene_ready.entity,
|
||||||
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user