0

I am Trying out the newest version of bevy.

how can I access MyRessource in the function two?

I would expect using .chain() on the tuple of systems would execute one system after another.

use bevy::prelude::*;

#[derive(Resource)]
struct MyResource(
    f32
);

fn main() {
    App::new()
        .add_startup_systems(
            (one, between, two).chain()
        )

        .run()
}

fn one(mut commands: Commands) {
    info!("before | inserting Resource ...");
    commands.insert_resource(MyResource(6.9));
}

fn between() {
    info!("between");
}

fn two(_my_resource: Res<MyResource>) {
    info!("after | managed to receive resource");
}

I tried to order 3 startup-system one after another to load Resource created in a different system.

reyop
  • 3
  • 1

1 Answers1

0

The bevy Discord server was able to help me. I have to insert a flush between the two Systems:

.add_startup_system(two.in_base_set(StartupSet::PostStartup))

my proper script would look like this:

use bevy::prelude::*;

#[derive(Resource)]
struct MyResource(
    f32
);

fn main() {
    App::new()
        .add_startup_system(one)
        .add_startup_system(between)
        .add_startup_system(two.in_base_set(StartupSet::PostStartup))


        .run()
}

fn one(mut commands: Commands) {
    info!("before | inserting Resource ...");
    commands.insert_resource(MyResource(6.9));
}

fn between() {
    info!("between");
}

fn two(_my_resource: Res<MyResource>) {
    info!("after | managed to receive resource");
}
reyop
  • 3
  • 1