fix duplicate id in tree viewer
This commit is contained in:
parent
7a3d51a626
commit
db8657bb96
1 changed files with 20 additions and 17 deletions
37
src/ui.rs
37
src/ui.rs
|
@ -71,7 +71,7 @@ pub fn action_bar_sys(
|
|||
|
||||
pub fn shape_tree_sys(
|
||||
mut egui_ctx: ResMut<EguiContext>,
|
||||
shapes: Query<&ShapeData>,
|
||||
shapes: Query<(Entity, &ShapeData)>,
|
||||
mut transforms: Query<&mut Transform>,
|
||||
) {
|
||||
if !shapes.is_empty() {
|
||||
|
@ -80,23 +80,26 @@ pub fn shape_tree_sys(
|
|||
.title_bar(true)
|
||||
.resizable(false)
|
||||
.show(egui_ctx.ctx_mut(), |ui| {
|
||||
for sd in shapes.iter() {
|
||||
ui.collapsing(format!("{:?}", sd.shape), |ui| {
|
||||
for (e, sd) in shapes.iter() {
|
||||
ui.push_id(e.id(), |ui| {
|
||||
|
||||
if let Ok(mut t) = transforms.get_mut(sd.main_shape) {
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Translation:");
|
||||
hui.add(egui::DragValue::new(&mut t.translation.x));
|
||||
hui.add(egui::DragValue::new(&mut t.translation.y));
|
||||
});
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Rotation:");
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
ui.collapsing(format!("{:?}", sd.shape), |ui| {
|
||||
|
||||
if let Ok(mut t) = transforms.get_mut(sd.main_shape) {
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Translation:");
|
||||
hui.add(egui::DragValue::new(&mut t.translation.x));
|
||||
hui.add(egui::DragValue::new(&mut t.translation.y));
|
||||
});
|
||||
ui.horizontal(|hui| {
|
||||
hui.label("Rotation:");
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue