bevy-inspector-egui
bevy-inspector-egui copied to clipboard
`InspectorQuery::<T>` does not apply mutations
This was already broken for me in 0.8.0, and still in 0.8.1.
Any of these forms work as expected:
.add_plugin(WorldInspectorPlugin::new())
// OR
.add_plugin(InspectorPlugin::<InspectorQuerySingle<Entity, With<Animator<Transform>>>>::new())
But this form produces an inspector that, when a value is mutated (here, the Animator<T>::state field), does not mutate the target component:
.add_plugin(InspectorPlugin::<Animator<Transform>>::new())
The generic Animator<T> is defined as:
#[derive(Component)]
#[cfg_attr(feature = "bevy_inspector_egui", derive(Inspectable))]
pub struct Animator<T: Component> {
pub state: AnimatorState, // some Inspectable-derived C-style enum
#[cfg_attr(feature = "bevy_inspector_egui", inspectable(ignore))]
prev_state: AnimatorState,
#[cfg_attr(feature = "bevy_inspector_egui", inspectable(ignore))]
tweenable: Option<Box<dyn Tweenable<T> + Send + Sync + 'static>>,
}
...and the bevy_inspector_egui feature is used.
The InspectorPlugin<T> will insert and edit T as a resource, not for components.
So if you want to edit one component of a single entity, you should use .add_plugin(InspectorPlugin::<InspectorQuerySingle<&'static mut Animator<Transform>>>::new()).
Ah good to know, I didn't know about the resource vs. component distinction. Maybe it's worth calling out in the README, where InspectorPlugin<T> is immediately pointed in the Usage section but without that clarification?
InspectorQuery doesn't exist anymore, so fixed.
but it is now easy to do it yourself:
let mut query = world.query_filtered::<Entity, With<Animator<Transform>>>();
for entity in query.iter(world) {
bevy_inspector_egui::bevy_inspector::ui_for_entity[_with_children](world, entity, ui);
}