fix duplicate id in tree viewer

This commit is contained in:
Rusty Striker 2022-07-30 17:50:52 +03:00
parent 7a3d51a626
commit db8657bb96

View file

@ -71,7 +71,7 @@ pub fn action_bar_sys(
pub fn shape_tree_sys( pub fn shape_tree_sys(
mut egui_ctx: ResMut<EguiContext>, mut egui_ctx: ResMut<EguiContext>,
shapes: Query<&ShapeData>, shapes: Query<(Entity, &ShapeData)>,
mut transforms: Query<&mut Transform>, mut transforms: Query<&mut Transform>,
) { ) {
if !shapes.is_empty() { if !shapes.is_empty() {
@ -80,23 +80,26 @@ pub fn shape_tree_sys(
.title_bar(true) .title_bar(true)
.resizable(false) .resizable(false)
.show(egui_ctx.ctx_mut(), |ui| { .show(egui_ctx.ctx_mut(), |ui| {
for sd in shapes.iter() { for (e, sd) in shapes.iter() {
ui.collapsing(format!("{:?}", sd.shape), |ui| { ui.push_id(e.id(), |ui| {
if let Ok(mut t) = transforms.get_mut(sd.main_shape) { ui.collapsing(format!("{:?}", sd.shape), |ui| {
ui.horizontal(|hui| {
hui.label("Translation:"); if let Ok(mut t) = transforms.get_mut(sd.main_shape) {
hui.add(egui::DragValue::new(&mut t.translation.x)); ui.horizontal(|hui| {
hui.add(egui::DragValue::new(&mut t.translation.y)); hui.label("Translation:");
}); hui.add(egui::DragValue::new(&mut t.translation.x));
ui.horizontal(|hui| { hui.add(egui::DragValue::new(&mut t.translation.y));
hui.label("Rotation:"); });
let mut rot = t.rotation.to_euler(EulerRot::XYZ).2.to_degrees(); ui.horizontal(|hui| {
if hui.add(egui::DragValue::new(&mut rot).suffix("°")).changed() { hui.label("Rotation:");
t.rotation = Quat::from_rotation_z(rot.to_radians()); let mut rot = t.rotation.to_euler(EulerRot::XYZ).2.to_degrees();
} if hui.add(egui::DragValue::new(&mut rot).suffix("°")).changed() {
}); t.rotation = Quat::from_rotation_z(rot.to_radians());
} }
});
}
});
}); });
} }
}); });