-
-
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
Make Visibility
optional in most built-in systems
#5258
Comments
I like the idea to have fewer built-in mandatory components. If this goes on, we may end with tons of mandatory components in the future and when users add something, it expects to be visible, as default behavior. But If that's the case, I think we should rename (again) the |
I feel this change is a fair and smart change overall considering not everything needs skippable visibility. I do agree with afonsolage regarding renaming the component to |
No, we should certainly not change the behavior of What I'm proposing is that:
There's a major difference between items whose visibility is dynamically and periodically/often toggled at runtime (for example, the check mark of a checkbox widget in UI) and items which are visible from the moment they're spawned to the moment they're despawned. And using visibility for hiding items for longer periods (like, hide the main menu while playing the game) is not desirable, because you often want to recover the resources used by those items not in use (especially, the GPU resources). In that latter case, |
I'd like to get the opinion of rendering folks on this. @james7132 or @superdump maybe when you have a minute? (thanks!) I can start a PR change as an example, but I'd like to make sure there's agreement in principle before I start any work, to avoid wasted time :) |
Relevant Mr about marker components: #3796 |
For clarity, this is the code I'm using in my own system where I query if !maybe_visibility.map_or(true, |vis| vis.is_visible) {
continue; // skip this entity
} |
Adding another argument. I just discovered in the dev docs that |
I think @cart decided to go in a different direction when we merged the recent visibility inheritance changes, added visibility to all rendered bundles, and added |
What was the rationale? If this was already acted as the solution, then this issue should probably be closed as "Won't Fix". And that direction conflicts with the |
What problem does this solve or what need does it fill?
Many built-in systems (e.g.
extract_text2d_sprite()
query a core component they want to update (e.g.Text
) with an associated unconditionalVisibility
component. If removed, the system doesn't run on theEntity
. However, most components (and especially the ones directly related to rendering) should be assumed visible by default. The ability to dynamically control the visibility of a render item should be an additional opt-in feature, not a default one.What solution would you like?
Replace
Visibility
withOption<Visibility>
in the query of most built-in systems, and treatNone
asVisibility::is_visible == true
.What alternative(s) have you considered?
Do nothing. This forces adding many unused
Visibility
components for all entities that are never going to be hidden (they might be deleted, but not dynamically shown/hidden).Additional context
The more "mandatory" components in a built-in system, the more difficult it is to reuse the built-in Bevy components. I'm trying to use
Text
to render some text, but with some properties (notably, the position, but also the visibility) controlled by my own framework. I could go rewrite from scratch a text rendering pipeline, but it feels like reusing the existing one is probably the best course of action. However currently theextract_text2d_sprite()
system forces adding 3 extra components in addition ofText
, which I argue is too much and at leastVisibility
should be optional (if not others; alignment could also be made optional for the cases where there's no need to align).The text was updated successfully, but these errors were encountered: