Bevy version and features
bevy = { version = "0.19.0-rc.2", default-features = false, features = ["2d", "ui", "bevy_feathers"] }
What you did
I'm trying to create a bsn-based UI function that marks components with an enum variant. The bsn documentation suggests this should be possible. However when passing in an enum variant to the ui function and including it in the bsn macro, I get a compiler error.
What went wrong
I'm trying to create a function that returns a bsn Scene for UI. If I pass in an enum value to the function, it has a compiler error
the trait bound `MyEnum: bevy::prelude::Scene` is not satisfied
the following other types implement trait `bevy::prelude::Scene`:
()
(P0, P1)
(P0, P1, P2)
(P0, P1, P2, P3)
(P0, P1, P2, P3, P4)
(P0, P1, P2, P3, P4, P5)
(P0, P1, P2, P3, P4, P5, P6)
(P0, P1, P2, P3, P4, P5, P6, P7)
and 15 others
I can resolve this by
Additional information
Minimal example.
use bevy::{feathers::FeathersPlugins, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(FeathersPlugins)
.add_systems(Startup, scene_list.spawn())
.run();
}
#[derive(Component, Clone, Default)]
enum MyEnum {
#[default]
A,
}
fn scene_list() -> impl SceneList {
bsn_list![ui(MyEnum::A)]
}
fn ui(enum_val: MyEnum) -> impl Scene {
bsn! {
enum_val
}
}
Working alternatives:
#[derive(Component, Clone, Default)]
struct MyEnumWrapper(pub MyEnum);
fn ui(enum_val: MyEnum) -> impl Scene {
bsn! {
MyEnumWrapper(enum_val)
}
}
or
// requires explicit `FromTemplate` on `MyEnum`
fn ui(enum_val: MyEnum) -> impl Scene {
bsn! {
MyEnum::A
}
}
Bevy version and features
What you did
I'm trying to create a bsn-based UI function that marks components with an enum variant. The
bsndocumentation suggests this should be possible. However when passing in an enum variant to theuifunction and including it in thebsnmacro, I get a compiler error.What went wrong
I'm trying to create a function that returns a
bsnScenefor UI. If I pass in an enum value to the function, it has a compiler errorI can resolve this by
FromTemplateon the enum and hard coding the enum variant in theui()function. Maybe related to Enums not working in bsn! macro without explicit FromTemplate derive #24469)enum_val, addMyEnumWrapper(enum_val)Additional information
Minimal example.
Working alternatives:
or