| Crates.io | bevy_audio_controller_derive |
| lib.rs | bevy_audio_controller_derive |
| version | 0.4.0 |
| created_at | 2024-11-05 20:27:19.990095+00 |
| updated_at | 2025-05-01 19:45:26.521428+00 |
| description | Derive macros for bevy_audio_controller |
| homepage | https://github.com/TurtIeSocks/bevy_audio_controller |
| repository | https://github.com/TurtIeSocks/bevy_audio_controller |
| max_upload_size | |
| id | 1437128 |
| size | 9,844 |
An extremely convenient plugin that provides a solid audio controller for Bevy with very minimal boilerplate!
AssetServer directly and provides a convenient enum so you can avoid "magic strings" in your coderegister_audio_channel trait to allow you to easily add multiple audio channels to your appAudioChannel derive macro adds convenient methods to the channel marker structuse bevy::{prelude::*, audio::PlaybackSettings};
use bevy_audio_controller::prelude::*;
#[derive(Component, Default, AudioChannel)]
struct SfxChannel;
type SfxEvent = PlayEvent<SfxChannel>;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(AudioControllerPlugin)
.register_audio_channel::<SfxChannel>()
.add_systems(Update, play_fire)
.run();
}
fn play_fire(mut ew: EventWriter<SfxEvent>) {
// even though this is called on every frame, it will only be played once the previous clip has finished
ew.write(SfxEvent::new(AudioFiles::FireOGG).with_settings(PlaybackSettings::DESPAWN));
}
defaultNone
logEnables logging with bevy/bevy_log
inspectAdds additional reflection traits to the structs used by this plugin to make them available in bevy-egui-inspector
Requires that channel components must also derive Reflect
// If you are using the `inspect` feature conditionally, you can use the following pattern
#[derive(Component, Default, AudioChannel)]
#[cfg_attr(feature = "inspect", derive(Reflect))]
#[cfg_attr(feature = "inspect", reflect(Component))]
struct SfxChannel;
// Otherwise, this is fine
#[derive(Component, Default, AudioChannel, Reflect)]
#[reflect(Component)]
struct MusicChannel;
mp3Enables support for MP3 audio files.
oggEnables support for OGG audio files
flacEnables support for FLAC audio files
wavEnables support for WAV audio files
all-codecsEnables support for all audio codecs
All examples require --features="ogg" flag to work. If you would like to view more details with bevy-egui-inspector, run with --all-features instead.
Demonstrates:
Inputs:
cargo run --example basic --features="ogg"
Demonstrates:
cargo run --example channels --features="ogg"
Demonstrates:
Inputs:
cargo run --example event_options --features="ogg"
Demonstrates:
Inputs:
DelayMode::Immediate cargo run --example ecs --features="ogg"
Demonstrates:
Percent & Milliseconds variations of the DelayMode enum for finer control over when a track is played cargo run --example delays --features="ogg"
Demonstrates:
Inputs:
cargo run --example volume --features="ogg"
Demonstrates:
cargo run --example querying --features="ogg"
| bevy | bevy_audio_controller |
|---|---|
| 0.16 | 0.4 |
| 0.15 | 0.3 |
| 0.14 | 0.2 |