| Crates.io | bevy-convars |
| lib.rs | bevy-convars |
| version | 0.2.1 |
| created_at | 2025-04-12 08:30:42.762567+00 |
| updated_at | 2025-04-26 05:14:18.321147+00 |
| description | An implementation of convars (config or console variables) for configuring your Bevy application. |
| homepage | |
| repository | https://github.com/transcendental-experiences/bevy-convars |
| max_upload_size | |
| id | 1630734 |
| size | 135,625 |
This is a crate that provides an implementation of Convars (console variables or config variables depending on who you ask), provided as bevy resources, with support for serialization, change detection, and the works. Convars are presented as resources within the Bevy world, and can be accessed as such without any special code.
bevy_convars::cvar_collection! {
pub struct RenderCVars & RenderCVarsMut {
enable_xr = cvar EnableXr("render.enable_xr", CVarFlags::SAVED): bool = false,
enable_renderdoc = cvar EnableRenderdoc("render.enable_renderdoc", CVarFlags::LOCAL): bool = false,
/*
* Anti-aliasing
*/
aa_method = cvar AaMethod("render.aa.method", CVarFlags::SAVED | CVarFlags::RUNTIME): AntialiasMethod = AntialiasMethod::Fxaa,
fxaa_sensitivity = cvar FxaaSensitivty("render.aa.fxaa_sensitivity", CVarFlags::SAVED | CVarFlags::RUNTIME): FxaaSensitivity = FxaaSensitivity::Medium,
msaa_samples = cvar MsaaSamples("render.aa.msaa_samples", CVarFlags::SAVED | CVarFlags::RUNTIME): MsaaSamplingConfig = MsaaSamplingConfig::Msaa4,
/*
* SSAO.
*/
enable_ssao = cvar EnableSsao("render.ssao.enabled", CVarFlags::SAVED | CVarFlags::RUNTIME): bool = true,
ssao_quality = cvar RenderSsaoQuality("render.ssao.quality", CVarFlags::SAVED | CVarFlags::RUNTIME): SsaoQuality = SsaoQuality::High,
ssao_object_thickness = cvar SsaoObjectThickness("render.ssao.object_thickness", CVarFlags::SAVED | CVarFlags::RUNTIME): f32 = 0.25
}
pub struct RenderCVarsPlugin;
}
fn my_system(
cvars: RenderCVars,
enable_ssao: Res<EnableSsao>,
mut commands: Commands,
) {
// Can read directly out of the RenderCVars param..
let aa_method = **cvars.aa_method;
// or from a specific cvar resource.
// All CVar types implement Deref and DerefMut for their inner type to make them easy to unpack and modify.
let ssao_on = **enable_ssao;
// ...
}
This crate is a bit early, and while it likely can replace your existing solution it needs some elbow grease to use outside of the supported use cases.
Contributions are welcome!
This library tracks Bevy's releases, at this time the following holds:
| Bevy Version | bevy-convars Version |
|---|---|
| 0.16.0 | 0.2.0 |
This work is available under EITHER the Apache 2.0 license (as provided in LICENSE-APACHE) or the MIT license (as provided in LICENSE-MIT).