How to Type returning a System from a function without typing all parameters (i.e a "System" type?) #19271
Answered
by
hymm
Joel-Singh
asked this question in
Q&A
-
Wrote this higher-order function returning a system for a current project, in Bevy 0.16.0, that lets me easily set the text of a "MessageBox": fn set_message(message: String) -> impl Fn(Commands, Single<Entity, With<MessageBox>>) {
return move |mut commands: Commands, message_box: Single<Entity, With<MessageBox>>| {
commands
.entity(*message_box)
.insert(Text::new(message.clone()));
};
} Is there a type I can put for the return value, instead of typing out every parameter with Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
hymm
May 19, 2025
Replies: 1 comment 1 reply
-
if you're trying to insert the system into a schedule you can do this: fn set_message(message: String) -> ScheduleConfigs<ScheduleSystem> {
return (move |mut commands: Commands, message_box: Query<Entity, With<Ray>>| {
commands
.entity(message_box.single().unwrap())
.insert(Text::new(message.clone()));
})
.into_configs();
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Joel-Singh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you're trying to insert the system into a schedule you can do this: