ui.label("Position");
ui.horizontal(|ui|
{
// Has user moved the shape or not
let mut update_position = false;
for position in object.1.position.iter_mut()
{
ui.label(format!("{}:", position.axis as char));
// Use Response::changed or whatever to determine if the value has been changed
if ui.add(egui::DragValue::new(&mut position.value).speed(editor_settings.slider_speed)).changed()
{
//println!("Changed!");
update_position = true;
}
}
// Updates the shape's position if the user has changed its value
if update_position == true
{
//println!("update_position: {update_position}");
gameengine_objects
.get_mut(&object.0.label.0)
//.get_mut("Object 0")
.unwrap()
.position(object.1.position[0].value, object.1.position[1].value, object.1.position[2].value);
}
});
ui.separator();
ui.label("Scale");
ui.horizontal(|ui|
{
let mut update_scale = false;
for scale in object.1.scale.iter_mut()
{
ui.label(format!("{}:", scale.axis as char));
if ui.add(egui::DragValue::new(&mut scale.value).speed(editor_settings.slider_speed)).changed()
{
update_scale = true;
}
}
if update_scale == true
{
println!("object.0.label.0: {}", object.0.label.0);
gameengine_objects
.get_mut(&object.0.label.0)
.unwrap()
.scale(object.1.scale[0].value, object.1.scale[1].value, object.1.scale[2].value);
}
});
So as you can see if I am only moving the scale, it will only update the shape's scale and nothing else. If I am only moving the position, then it will only update the position.
The issue is that if I update the scale property, the scale change does not come into effect until I changed the position.
Here is my code for updating position and scale
So as you can see if I am only moving the scale, it will only update the shape's scale and nothing else. If I am only moving the position, then it will only update the position.
The issue is that if I update the scale property, the scale change does not come into effect until I changed the position.
Here is a gif to explain to you what is going on: