Crates.io | bevy-settings |
lib.rs | bevy-settings |
version | 0.6.0 |
source | src |
created_at | 2023-01-19 21:19:14.067639 |
updated_at | 2024-07-05 17:23:03.89709 |
description | Use a simple struct as persistent settings between game launches. Usefull for e.g. storing the audio settings |
homepage | |
repository | https://github.com/tecbeast42/bevy-settings |
max_upload_size | |
id | 762937 |
size | 126,605 |
The goal of this project is to store settings in a resource throughout game launches.
Currently this crate supports Linux, Mac and Windows.
The crate will choose the appropriate path for each OS to store the config file.
This example will generate a config file on your system but it probably will not hurt you if you pick something non existent
use bevy::prelude::*;
use bevy_settings::{Serialize, Deserialize};
#[derive(Resource, Default, Serialize, Deserialize, Clone, Copy)]
#[serde(crate = "bevy_settings::serde")]
struct Settings {
master_volume: f64,
custom_cursor: bool,
}
fn main () {
App::new()
.add_plugin(bevy_settings::SettingsPlugin::<Settings>::new(
"My awesome game studio",
"The name of the game"
))
.run();
}
on e.g. my linux machine this will create
❯ cat ~/.config/myawesomegamestudio/My awesome game studio.toml
master_volume = 0.0
custom_cursor = false
TestSetting(u32)
does not work but TestSetting{ test: u32 }
works fine.Checkout the basic example to see how to persist the configuration.
Version | Bevy Version |
---|---|
0.1.0 | 0.9 |
0.2.0 | 0.10 |
0.3.1 | 0.11 |
0.4.0 | 0.12 |
0.5.0 | 0.13 |
0.6.0 | 0.14 |