jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.15k stars 169 forks source link

Inspect a State<T> resource #89

Closed Xion closed 1 year ago

Xion commented 1 year ago

This doesn't appear to be possible currently. Code similar to:

#[derive(Inspectable)]
enum GameState { Menu, InGame }

#[derive(Inspectable)]
struct Root {
    game_state: ResourceInspector<State<GameState>>,
}

makes rustc complain about State not implementing Inspectable. If adding such impl doesn't work, introducing a dedicated StateInspector could work equally well.

(Bonus point for support iyes_loopless states, too ;-) )

jakobhellermann commented 1 year ago

This would be fixed by adding an implementation of Inspectable for State<T: Inspectable>.

But since bevy 0.9 will release soon and I have been planning a rewrite of bevy-inspector-egui replacing Inspectable with Reflect I don't think this is worth fixing for the time being.

In the rewrite, I added a StateInspectorPlugin<T> that can used, and there is a ui_for_state<T> helper function which can be used as well in a custom UI function.

Xion commented 1 year ago

That sounds great! Looking forward to the rewrite. Using Reflect rather than custom trait should definitely improve usability. Thanks!

jakobhellermann commented 1 year ago

the rewrite is now published as 0.16