umut-sahin / bevy-persistent Goto Github PK
View Code? Open in Web Editor NEWA Bevy helper to easily manage resources that need to persist across game sessions.
License: Apache License 2.0
A Bevy helper to easily manage resources that need to persist across game sessions.
License: Apache License 2.0
I use bevy_asset_loader for loading assets when entering a loading state. I wanted to load something using this crate as well and still get the same state management (progress/error/etc.) features provided by bevy_asset_loader.
In order to use it with this crate, Persistent<T>
would need to implement Asset
and have a custom AssetLoader
along with registering them in the plugin. For bevy_asset_loader, it would also require custom DynamicAsset
but that doesn't technically require any change in this crate (unless you'd want to support bevy_asset_loader
behind a feature flag).
Two additional point:
Res(Mut)<Assets<Persistent<T>>>
instead of Res(Mut)<Persistent<T>>
(only if loaded via AssetLoader
, the existing codepath could keep it as the latter).AssetLoader::load
returns a Future
but this crate does synchronous loading. I'm assuming the work could be done on one of Bevy's task pools to avoid blocking. Or this crate could expose an async loading interface (maybe just internally for the AssetLoader
).Wanted to gauge whether this is something you'd want supported by this crate. If so, I'd be willing to send a PR out to do so. Let me know if I've missed anything, thanks!
... can be useful for implementing auto saves, manual saves, and periodic saves.
Hi, I really like this plugin!
If I change my resource that I want to persist, when a persisted file already exists, it fails to read it. so in the recent update i can make it reverse it to the default, which is nice.
But is it maybe possible to add the new fields with the default value and not reset everything?
For example if my players save their custom keybindings and i then update those keybindings and add new ones, all of their settings would be reset, which is quite annoying :)
As far as I can tell, the crate doesn’t really do anything without a backend (correct me if I’m wrong).
Thus something along the following lines would be nice:
cfg!(not(any(feature = "…", feature = "…", …)))
compile_error!("A helpful message to the developer telling them to enable a feature")
... can be very useful to for certain persistent resources.
... can be useful for some persistent resources.
... can be very useful in certain situations.
We currently log the error and then ignore it. We can do better by explicitly returning a Result
with an appropriate error type. Users would be free to ignore the errors using .ok()
like before, but they'd have the ability to handle them as they see fit.
Hey, I think we might be trying to solve the same problem?
Just wondered if you looked at bevy_pkv? And if so, how is persistent different?
... can be very useful during development.
It would be nice if bevy-persistent would also work for WASM. One option (suggested in Reddit) is to use gloo-storage. Another option is to use bevy_pkv as a backend, since it already supports both native and WASM with the same API.
Could be good for debugging with something like https://github.com/jakobhellermann/bevy-inspector-egui.
... can save a lot of memory and startup time for certain situations.
bevy-persistent = { version = "*", features = ["ron", "pretty"] }
Compiling bevy-persistent v0.3.0
error[E0425]: cannot find value `serialized_resource_str` in this scope
--> _<PATH HIDDEN>_\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy-persistent-0.3.0\src\format.rs:174:36
|
174 | ron::from_str::<R>(serialized_resource_str).map_err(|error| {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `serialized_resource`
error[E0425]: cannot find value `serialized_resource_str` in this scope
--> _<PATH HIDDEN>_\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy-persistent-0.3.0\src\format.rs:181:36
|
181 | ron::from_str::<R>(serialized_resource_str).map_err(|error| {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `serialized_resource`
For more information about this error, try `rustc --explain E0425`.
error: could not compile `bevy-persistent` (lib) due to 2 previous errors
Add feature "toml". This will trigger the macro at line number 141 and will create serialized_resource_str
I tried to modify the line 141 (add feature = "ron"
), but this seems to be more complicated issue.
... can be very useful to save memory, or bring external modifications to the application without restarting the application.
Since JSON is supported, it would make sense to also support RON, since in the Bevy ecosystem it is also used in place of JSON (see e.g. DynamicScene
s)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.