Overwrite gizmo group in insert_gizmo_group (#11860)

# Objective

I tried using `insert_gizmo_group` to configure my physics gizmos in a
bevy_xpbd example, but was surprised to see that nothing happened. I
found out that the method does *not* overwrite gizmo groups that have
already been initialized (with `init_gizmo_group`). This is unexpected,
since methods like `insert_resource` *do* overwrite.

## Solution

Insert the configuration even if it has already been initialized.
This commit is contained in:
Joona Aalto 2024-02-14 18:20:16 +02:00 committed by GitHub
parent 0354ce4450
commit 8cf3447343
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -183,6 +183,10 @@ impl AppGizmoBuilder for App {
group: T,
config: GizmoConfig,
) -> &mut Self {
self.world
.get_resource_or_insert_with::<GizmoConfigStore>(Default::default)
.insert(config, group);
if self.world.contains_resource::<GizmoStorage<T>>() {
return self;
}
@ -190,10 +194,6 @@ impl AppGizmoBuilder for App {
self.init_resource::<GizmoStorage<T>>()
.add_systems(Last, update_gizmo_meshes::<T>);
self.world
.get_resource_or_insert_with::<GizmoConfigStore>(Default::default)
.insert(config, group);
let Ok(render_app) = self.get_sub_app_mut(RenderApp) else {
return self;
};