Expand description
This is a plugin implementing OSC for bevy using rosc.
Usage
First you need to add the dispatcher as a resource to your app. Then add an OscMethod component to your entity. The dispatcher will now deliver all OSC messages that match the method’s address to your component.
use bevy::prelude::*;
use bevy_rosc::OscDispatcher;
use bevy_rosc::OscMethod;
#[derive(Component)]
struct ExampleEntity;
#[derive(Bundle)]
#[derive(Component)]
struct ExampleBundle {
_t: ExampleEntity,
receiver: OscMethod,
}
fn spawn(mut commands: Commands) {
commands.spawn_bundle(ExampleBundle {
_t: ExampleEntity,
receiver: OscMethod::new(vec!["/some/address"]).expect(""),
});
}
fn osc_printer(mut query: Query<&mut OscMethod, (Changed<OscMethod>)>) {
for mut osc_method in query.iter_mut() {
match osc_method.get_message() {
Some(message) => println!("Method {} received: {:?}", osc_method.get_addresses()[0], message),
None => {}
}
}
}
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.insert_resource(OscDispatcher::default())
.add_system(osc_printer)
.run()
}Structs
Bevy component that can receive OSC messages at one or multiple addresses