#Accessing App Resources Outside of Systems?
14 messages · Page 1 of 1 (latest)
Basically, a way to access them without adding them as a system to the App::new() function.
you mean by having still access to the app? like app.world.resource::<T>()?
Yeah, having access to the app, even in functions that are not passed as systems to App::new().
that should work then, right?
Can I have a code example?I don't quite understand.
app.world.resource::<type of the resource>()
and the mut version
app.world.resource_mut::<type of the resource>()
These fetch the resource having an app instance.
How are you getting app!?
use bevy::prelude::*;
/* Code for MyResource */
fn main() {
App::new()
.insert_resource(MyResource::new())
/* New App Code */
.run();
}
fn some_random_function_not_added_as_a_system() {
/* Code for accessing MyResource from App!? How to do that... */
}
@burnt summit
Can you fill in the gaps for me?
I really need a full-ish example to help.
Like, not an entire game, just like a simple 15 line main.rs file.
Something simple, but complete.