let user run a function on a scene entities#1058
Conversation
fc925c0 to
cb84651
Compare
| self.spawned_instances.contains_key(&instance_id) | ||
| } | ||
|
|
||
| pub fn for_entity_in_scene_instance(&self, instance_id: InstanceId, mut f: impl FnMut(Entity)) { |
There was a problem hiding this comment.
Thoughts on removing for_entity_in_scene_instance in favor of:
fn iter_instance_entities(&self, instance_id: InstanceId) ->
Option<impl Iterator<Item=Entity>> {
self.spawned_instances
.get(&instance_id)
.map(|instance| instance.entity_map.values.cloned())
}There was a problem hiding this comment.
I think it would make it a bit more flexible
There was a problem hiding this comment.
good idea! I tried using the same idea as for_current_entity but this seems better
There was a problem hiding this comment.
Yeah i'm not a huge fan of for_current_entity, but the builder pattern sort of forced my hand / i consider it to be an exception rather than a rule. SceneSpawner isn't a builder so I don't feel constrained in the same way.
|
changed to provide |
|
@mockersf On my Intel Mac I see only a blank gray window without any console errors when I run |
add scene instance entity iteration (cherry picked from commit c25b41a)
make
InstanceIdof a spawned scene availablecheck that a scene instance has been spawned (it takes 1 frame for the scene to spawn + x frames while the asset (gltf) is loaded)
run a function on entities from a spawned scene
also added an example for this PR and #1026