bevy_mod_config

Crates.iobevy_mod_config
lib.rsbevy_mod_config
version0.2.2
created_at2025-07-09 16:46:42.457223+00
updated_at2025-07-18 15:52:47.7507+00
descriptionA Bevy plugin for configuration management
homepage
repositoryhttps://github.com/SOF3/bevy_mod_config
max_upload_size
id1745149
size226,578
Jonathan Chan Kwan Yin (SOF3)

documentation

README

bevy_mod_config

A bevy plugin for configuration management.

Concepts

  • Scalar: A non-composite config type, e.g. a number, string, color, direction, etc.
  • Root field: A top-level config field directly registered to the app.
  • Manager: A plugin that works on scalar config fields.
  • Reader: A type derived from #[derive(Config)] that can be used to access config values through ReadConfig in systems.

Usage

Declare one or more config hierarchies with #[derive(Config)]:

#[derive(Config)]
struct Foo {
    thickness: i32,
    color:     Color,
}

#[derive(Config)]
#[config(expose(read))] // Expose the generated `ColorRead`
enum Color {
    White,
    Black,
}

Initialize the root field with App::init_config:

type ManagerType = (Manager1, Manager2, ...);
    bevy_mod_config::ScalarManager,
)

app.init_config::<ManagerType, Foo>("foo");

Root fields can be accessed from systems using ReadConfig:

fn my_system(foo: ReadConfig<Foo>) {
    let foo = foo.read();
    assert_eq!(foo.thickness, 3);
    assert!(matches!(foo.color, ColorRead::White));
}

Note that read() returns the Reader type instead of the original type (similar to how #[derive(QueryData)] gives XxxItem to systems). This may have an impact on matching and passing values around. The Reader type may be accessed as <Foo as ConfigField>::Read<'_>, or directly exposed with #[config(expose(read))] after the derive.

Managers

Managers enable systematic management of scalar config fields.

  • Storage:
    • bevy_mod_config::manager::Serde exposes APIs to load/save config values to/from serialized data.
  • Editors:
    • bevy_mod_config::manager::EguiEditor provides an in-game egui editor to modify config values live.
Commit count: 0

cargo fmt