mute audio in debug builds when run through cargo run

This commit is contained in:
yuni 2024-03-22 12:28:19 +01:00
parent 4a5a239639
commit 7780b90e8f
2 changed files with 15 additions and 4 deletions

View file

@ -17,9 +17,11 @@ Then run the following commands, replacing `[URL]` with the clone URL of the git
``` ```
git clone [URL] git clone [URL]
cd outfly 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 ## Building for Windows on Linux
``` ```

View file

@ -1,4 +1,5 @@
use bevy::prelude::*; use bevy::prelude::*;
use std::env;
#[derive(Resource)] #[derive(Resource)]
pub struct Settings { pub struct Settings {
@ -36,9 +37,17 @@ pub struct Settings {
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
// Mute audio by default in debug builds let default_mute_sfx;
let default_mute_sfx = cfg!(debug_assertions); let default_mute_music;
let default_mute_music = cfg!(debug_assertions); 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 { Settings {
mute_sfx: default_mute_sfx, mute_sfx: default_mute_sfx,