Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dart messages to be easily handled as bevy events #349

Merged
merged 10 commits into from
Jun 30, 2024
3 changes: 3 additions & 0 deletions rust_crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rust-version = "1.70"
[features]
rt-multi-thread = ["tokio/rt-multi-thread"]
show-backtrace = ["backtrace"]
bevy = ["dep:bevy_ecs"]

[target.'cfg(not(target_family = "wasm"))'.dependencies]
os-thread-local = "0.1.3"
Expand All @@ -20,8 +21,10 @@ home = "0.5.9"
which = "6.0.0"
allo-isolate = "0.1.25"
tokio = { version = "1", features = ["rt"] }
bevy_ecs = { version = "0.13", optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
js-sys = "0.3.69"
wasm-bindgen = "0.2.92"
wasm-bindgen-futures = "0.4.42"
bevy_ecs = { version = "0.13", optional = true }
4 changes: 4 additions & 0 deletions rust_crate/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ use super::interface_os::*;
#[cfg(target_family = "wasm")]
use super::interface_web::*;

#[cfg(feature = "bevy")]
use bevy_ecs::event::Event;
/// This contains a message from Dart.
/// Optionally, a custom binary called `binary` can also be included.
/// This type is generic, and the message
/// can be of any type declared in Protobuf.
/// If the bevy feature is used, every message can be received as an event in Bevy.
#[cfg_attr(feature = "bevy", derive(Event))]
Deep-co-de marked this conversation as resolved.
Show resolved Hide resolved
pub struct DartSignal<T> {
/// The message instance of a struct generated by Protobuf.
pub message: T,
Expand Down