From 7780b90e8fdfee120de0321d3e7ee05a271c7355 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 22 Mar 2024 12:28:19 +0100 Subject: [PATCH] mute audio in debug builds when run through `cargo run` --- README.md | 4 +++- src/settings.rs | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e04be7b..97658ba 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,11 @@ Then run the following commands, replacing `[URL]` with the clone URL of the git ``` git clone [URL] cd outfly -cargo run +cargo run --release ``` +NOTE: Audio is muted by default when run through `cargo run`, unless you add `--release` + ## Building for Windows on Linux ``` diff --git a/src/settings.rs b/src/settings.rs index 231feb8..53fd3a5 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,4 +1,5 @@ use bevy::prelude::*; +use std::env; #[derive(Resource)] pub struct Settings { @@ -36,9 +37,17 @@ pub struct Settings { impl Default for Settings { fn default() -> Self { - // Mute audio by default in debug builds - let default_mute_sfx = cfg!(debug_assertions); - let default_mute_music = cfg!(debug_assertions); + let default_mute_sfx; + let default_mute_music; + if let Ok(_) = env::var("CARGO") { + // Mute audio by default when run through `cargo` + default_mute_sfx = cfg!(debug_assertions); + default_mute_music = cfg!(debug_assertions); + } + else { + default_mute_sfx = false; + default_mute_music = false; + } Settings { mute_sfx: default_mute_sfx,