Skip to content

Can I transfer a resource from the main world to the render world? #10129

Closed Answered by Supreeeme
Supreeeme asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I seem to have accomplished this by adding a system to ExtractSchedule with the MainWorld resource as a parameter:

let render_app = app.sub_app_mut(RenderApp);
render_app.add_systems(ExtractSchedule, get_comms.run_if(check_comms))

// ...

fn check_comms(maybe_comms: Option<Res<Comms>>) -> bool {
    maybe_comms.is_none()
}

fn get_comms(mut commands: Commands, mut world: ResMut<MainWorld>) {
    let comms = world.remove_resource::<Comms>().unwrap();
    commands.insert_resource(comms);
}

And now I can add a system to the render app that uses Comms. Not sure if there is a better way but works for me.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Supreeeme
Comment options

You must be logged in to vote
1 reply
@tombh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants