#settings #persistent #gamedev #config-file #launch #resources

bevy-settings

Use a simple struct as persistent settings between game launches. Usefull for e.g. storing the audio settings

10 releases (6 breaking)

0.6.0 Jul 5, 2024
0.5.1 Apr 5, 2024
0.5.0 Feb 20, 2024
0.4.0 Nov 8, 2023
0.0.2 Jan 19, 2023

#243 in Game dev

Download history 5/week @ 2024-07-20 59/week @ 2024-07-27 15/week @ 2024-08-03 23/week @ 2024-08-10 13/week @ 2024-08-17 9/week @ 2024-08-24 16/week @ 2024-08-31 2/week @ 2024-09-07 16/week @ 2024-09-21 11/week @ 2024-09-28 108/week @ 2024-10-05 52/week @ 2024-10-12 24/week @ 2024-10-19 21/week @ 2024-10-26 47/week @ 2024-11-02

158 downloads per month
Used in bevy-codex

MIT license

32KB
208 lines

Bevy Settings

License: MIT Doc Crate Build Status Bevy tracking

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.

Usage

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

Roadmap

  • multi storage support
  • file naming support
  • obfuscation support, this should just make it minimal hard to change the data, it is not really secure

Known limitations

  • the toml crate has problems with large numbers e.g. u64::MAX
  • there is a problem with tuple structs e.g. 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

Dependencies

~14–28MB
~343K SLoC