Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can spawn a scene from a ChildBuilder, or directly set its parent when spawning it #1026

Merged
merged 2 commits into from
Dec 9, 2020

Conversation

mockersf
Copy link
Member

@mockersf mockersf commented Dec 7, 2020

from ChildBuilder:

fn setup(
    commands: &mut Commands,
    asset_server: Res<AssetServer>,
) {
    commands
        .spawn((Transform::default(), GlobalTransform::default()))
        .with_children(|parent| {
            parent.spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf"));
        });
}

from SceneSpawner:

fn setup(
    commands: &mut Commands,
    asset_server: Res<AssetServer>,
    mut scene_spawner: ResMut<SceneSpawner>,
) {
    let parent = commands
        .spawn((Transform::default(), GlobalTransform::default()))
        .current_entity()
        .unwrap();

    scene_spawner.spawn_as_child(
        asset_server.load("models/FlightHelmet/FlightHelmet.gltf"),
        parent,
    );
}

@Moxinilian Moxinilian added A-ECS Entities, components, systems, and events C-Enhancement A new feature labels Dec 9, 2020
@cart
Copy link
Member

cart commented Dec 9, 2020

Awesome 😄

image

I think eventually we might want to force scenes to have a single root entity, but I'm not 100% sure at this point / we'll want to experiment. This looks good for now / unlocks some valuable usability.

@cart cart merged commit f53ee54 into bevyengine:master Dec 9, 2020
@fopsdev fopsdev mentioned this pull request Jan 24, 2021
@mockersf mockersf deleted the scene-as-child branch April 27, 2021 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants