Add parameters to setup ? #10763
Answered
by
rlidwka
ThomasCartier
asked this question in
Q&A
-
Hi, How may I add a parameter to the setup function ?
Or alternatively the best way to access it if it's not passed directly. I could't find an example that needs some external info for its setup. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
rlidwka
Nov 27, 2023
Replies: 1 comment 3 replies
-
Add a resource, then request it: App::new()
.add_plugins(MinimalPlugins)
.add_systems(Startup, setup)
.add_resource(PathToLoad("..."))
fn setup(mut commands: Commands, path: Res<PathToLoad>) {...} Alternatively, you can make a higher-order function, but that's pretty advanced: App::new()
.add_plugins(MinimalPlugins)
.add_systems(Startup, setup("path_to_load"))
fn setup(path: &str) -> impl SomeBlackMagic {
return move |commands: &Commands| {
todo!()
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ThomasCartier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a resource, then request it:
Alternatively, you can make a higher-order function, but that's pretty advanced: