Skip to content

render stages: Can't use an entity spawned in the same stage #6989

@dcz-self

Description

@dcz-self

Bevy version

0.9.1

What you did

The use case: I want to have a uniform which is created based on 2 separate sets of extracted data. I'm bound on one side by the Extract stage where the extraction takes place, and the Prepare stage, where the instantiated uniform is written to the buffer via UniformComponentPlugin.

There is no stage between them (adding a stage results in the system not running).

Ordering systems within one stage doesn't let the later systems see the result of the earlier. See the code below:

use bevy::prelude::*;
use bevy::render::{RenderApp, RenderStage};

fn main() {
    let mut app = App::new();
    if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
        render_app
            .add_system_to_stage(RenderStage::Prepare, spawner_system)
            .add_system_to_stage(RenderStage::Prepare, looker.after(spawner_system));
    }
    app.run();
}
#[derive(Component, Debug)]
struct MyUniform;

fn spawner_system(mut commands: Commands) {
    commands.spawn(MyUniform);
}

fn looker(query: Query<(Entity, &MyUniform)>) {
    for (e, u) in query.iter() {
        dbg!(e, u);
    }
}

What went wrong

Expected: something is printed, i.e. spawned etities are available in the next stage which is explicitly serialized.

Actual: nothing is printed. Entities available in the next stage (not illustrated here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions