bevyengine/bevy
bevy_settings
A small framework for saving and loading user preferences.
Purpose
Most games need a place to persist user choices — graphics quality, key bindings, language, audio volume — that's separate from save data. bevy_settings provides a typed, reflected wrapper that loads on startup, watches for changes, and writes to a JSON/RON file.
Directory layout
crates/bevy_settings/src/
├── lib.rs # SettingsPlugin
├── settings.rs # Settings trait + storage
└── …Key abstractions
| Type | File | Description |
|---|---|---|
SettingsPlugin<T> |
crates/bevy_settings/src/lib.rs |
Loads and saves a T: Settings resource. |
Settings (trait) |
crates/bevy_settings/src/settings.rs |
Marker trait — Reflect + Resource + Default. |
How it works
On startup, the plugin reads a per-platform user-preference path (via directories-crate logic or similar), deserializes the file, and inserts the value as a resource. A change-detection system watches the resource and writes back when it changes.
The actual file format is reflection-driven so any reflected struct can be a settings type.
Integration points
- Depends on:
bevy_app,bevy_ecs,bevy_reflect,serde,directoriesor platform-specific. - Depended on by: Apps that opt in.
Entry points for modification
- Custom storage path:
SettingsPlugin::<T>::with_path. - Custom format: add a saver trait alongside the existing serde-based one.
See also
bevy_reflect— drives serialization.- The
examples/usage/settings.rsexample demonstrates a typical use.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.