Compare commits
No commits in common. 'b91561d4fc9c06ade9ec11264df4d7455bca06e2' and '7621db220e7d1f61aa753beb0ef891abaa4ce5e4' have entirely different histories.
b91561d4fc
...
7621db220e
@ -0,0 +1,79 @@
|
||||
use crate::editor::prelude::*;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EditorGltfPlugin;
|
||||
|
||||
impl Plugin for EditorGltfPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Update, sync_asset_buttons::<Gltf>)
|
||||
.add_systems(Update, sync_remove_asset_buttons::<Gltf>)
|
||||
.add_systems(Update, gltf_ui);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Component, Default)]
|
||||
pub struct GltfWidget;
|
||||
|
||||
pub fn gltf_ui(
|
||||
mut events: EventReader<AssetEvent<Gltf>>,
|
||||
mut commands: Commands,
|
||||
widget: Query<Entity, With<GltfWidget>>,
|
||||
current: Query<(Entity, &ui::TargetAsset<Gltf>)>,
|
||||
server: Res<AssetServer>,
|
||||
) {
|
||||
events.iter().for_each(|event| match event {
|
||||
AssetEvent::Created { handle } => {
|
||||
info!("Asset created! {:?}", event);
|
||||
create_asset_button(
|
||||
&widget,
|
||||
&mut commands,
|
||||
ui::TargetAsset {
|
||||
handle: handle.clone(),
|
||||
},
|
||||
get_asset_name(&server, handle.clone()),
|
||||
None,
|
||||
);
|
||||
}
|
||||
AssetEvent::Removed { handle } => {
|
||||
info!("Asset removed! {:?}", event);
|
||||
destroy_asset_button(
|
||||
¤t,
|
||||
&mut commands,
|
||||
&ui::TargetAsset {
|
||||
handle: handle.clone(),
|
||||
},
|
||||
);
|
||||
}
|
||||
AssetEvent::Modified { handle } => {
|
||||
info!("Asset modified! {:?}", event);
|
||||
destroy_asset_button(
|
||||
¤t,
|
||||
&mut commands,
|
||||
&ui::TargetAsset {
|
||||
handle: handle.clone(),
|
||||
},
|
||||
);
|
||||
create_asset_button(
|
||||
&widget,
|
||||
&mut commands,
|
||||
ui::TargetAsset {
|
||||
handle: handle.clone(),
|
||||
},
|
||||
get_asset_name(&server, handle.clone()),
|
||||
None,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn control_active_gltf(
|
||||
events: Query<Entity, (With<ui::TargetAsset<Gltf>>, Added<ui::Active>)>,
|
||||
root: Query<Entity, With<LevelRoot>>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
events.iter().for_each(|_| {
|
||||
root.iter().for_each(|entity| {
|
||||
commands.entity(entity).despawn_descendants();
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue