bevy_pkv
bevy_pkv copied to clipboard
Automatic resource tracking
Hi. Thanks for making this plugin - it's unbelievably useful.
For my game I've built quite an ergonomic wrapper around it and I think might be worth adding something like it to this crate.
Basically, you call app.init_tracked_resource<T>() for some Resource, and then that resource gets initialized with the value in the PkvStore and every time the resource changes, the store updates. You never need to use the PkvStore directly.
Happy to contribute code / examples / documentation if this is considered worth adding.
@wainwrightmark any chance of sharing (part of) your implementation here for others to use, even if it isn't upstreamed into bevy_pkv?
Yes sounds very useful. Happy to accept a pr if the implementation is clean. Sorry i forgot to respond to this
Hi. I'm afraid I don't have a ton of time this week to write a PR but I might be able to soon.
If you want to use the code, I believe its all in these two files:
https://github.com/wainwrightmark/nice_bevy_utils/blob/main/src/lib.rs https://github.com/wainwrightmark/nice_bevy_utils/blob/main/src/tracked_resource.rs
Just looking at it now, it might also be worth adding:
- A way to control which schedule the changes are tracked in (currently
PostUpdate) - A way to handle store errors more gracefully
- A derive macro for
TrackableResource