mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 07:35:19 +00:00
add system, attempt to map to old path
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use bevy::app::{App, Plugin};
|
||||
use bevy::app::{App, Plugin, PostUpdate};
|
||||
use bevy::asset::{Assets, Handle};
|
||||
use bevy::pbr::StandardMaterial;
|
||||
use bevy::prelude::{Commands, Entity, Query, ResMut};
|
||||
use space_editor::prelude::EditorRegistryExt;
|
||||
use crate::material::short_material::ShortMaterial;
|
||||
|
||||
@@ -10,5 +13,26 @@ impl Plugin for MaterialPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.register_type::<ShortMaterial>()
|
||||
.editor_registry::<ShortMaterial>();
|
||||
|
||||
app.add_systems(PostUpdate, apply_short_materials);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_short_materials(
|
||||
mut commands: Commands,
|
||||
q_mats: Query<(Entity, &Handle<StandardMaterial>, &ShortMaterial)>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
for (entity, handle, short) in q_mats.iter() {
|
||||
let Some(material) = materials.get_mut(handle) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
material.base_color = short.base_color;
|
||||
material.perceptual_roughness = short.perceptual_roughness;
|
||||
material.metallic = short.metallic;
|
||||
material.reflectance = short.reflectance;
|
||||
|
||||
commands.entity(entity).remove::<ShortMaterial>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user