bevy_mod_picking
bevy_mod_picking copied to clipboard
SceneBundle Example
Would be really useful to have an example of how to get this work for the new SceneBundle. The method I use to use to get this to work was complicated and no longer seems to be working as of 0.8. (Using with_children and calling scene_spawner as the child and passing the returned instance_id off see if its spawned before adding the PickableBundle).
Ended up getting this to work with the code below. If there is any interest in adding this as an example id be willing to create one.
fn add_pickable(
mut commands: Commands,
scene_spawner: Res<SceneSpawner>,
scene_query: Query<(Entity, &SceneInstance, &Tree)>,
) {
for (scene_entity, scene_instance, _) in scene_query.iter() {
if let Some(entity_iter) =
scene_spawner.iter_instance_entities(**scene_instance)
{
entity_iter.for_each(|entity| {
commands
.entity(entity)
.insert_bundle(PickableBundle::default());
});
commands.entity(scene_entity).remove::<SceneInstance>();
}
}
}