Compare commits
5 Commits
7621db220e
...
b91561d4fc
| Author | SHA1 | Date |
|---|---|---|
|
|
b91561d4fc | 2 years ago |
|
|
fab810c007 | 2 years ago |
|
|
822c2de042 | 2 years ago |
|
|
f6384c036e | 2 years ago |
|
|
b3c225b1ad | 2 years ago |
@ -1,79 +0,0 @@
|
|||||||
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