-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add entity disabling example #17710
Add entity disabling example #17710
Conversation
The generated |
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.
Looks good! I love an interactive example, especially small ones like this. I have an alternate method for avoiding disabling the window and text entities suggested, and some minor documentation items.
examples/ecs/entity_disabling.rs
Outdated
// Just add the `Disabled` component to the entity to disable it. | ||
// Note that the `Disabled` component is *only* added to the entity, | ||
// its children are not affected. | ||
commands.entity(clicked_entity).insert(Disabled); |
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.
That's interesting! Since the entity is disabled, does that cause the parent/child relationship to break, orphaning those children? Or does the relationship stick around and the children just have a disabled parent?
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.
The latter :) I don't think much of our code is robust to it yet though!
examples/ecs/entity_disabling.rs
Outdated
|
||
fn disable_entities_on_click( | ||
trigger: Trigger<Pointer<Click>>, | ||
ignored_query: Query<(), Or<(With<Window>, With<Text>)>>, |
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.
This query is super fascinating to me cause you are querying for 'Void' with some stuff on it. I know that's not the point of this example, but what's the difference between this and just querying for all entities with those components and then doing an equality check on the entities below?
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.
This will avoid actually fetching / locking the data :) We don't actually care about the data contained inside!
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 ran this example and it works well! Only real feedback is on the visibility comment above, but I don't really think it matters all that much.
Co-authored-by: Zachary Harrold <[email protected]>
# Objective The entity disabling / default query filter work added in bevyengine#17514 and bevyengine#13120 is neat, but we don't teach users how it works! We should fix that before 0.16. ## Solution Write a simple example to teach the basics of entity disabling! ## Testing `cargo run --example entity_disabling` ## Showcase  --------- Co-authored-by: Zachary Harrold <[email protected]>
Objective
The entity disabling / default query filter work added in #17514 and #13120 is neat, but we don't teach users how it works!
We should fix that before 0.16.
Solution
Write a simple example to teach the basics of entity disabling!
Testing
cargo run --example entity_disabling
Showcase