-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make it a bit more flexible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea! I tried using the same idea as for_current_entity
but this seems better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
InstanceId
of 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