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
Ability to opt into change detection on *ReadOnlyItem
in mutable QueryData
derive
#12920
Comments
The |
Seems like a very reasonable request. Mild preference for approach two, with per-field attributes since it's a bit more flexible. |
@alice-i-cecile I think you misunderstood. There aren't two separate approaches here - I am proposing supporting both forms of usage, in a similar way to how serde has both |
Ah, I'm fine with that as well. |
I've come up with a (in my opinion) nicer way of achieving the goal here, which has been laid out in #13329. |
Closed in favour of #13329. |
What problem does this solve or what need does it fill?
Currently, the
QueryData
derive macro transforms fields of the type&'static mut T
toMut<'w, T>
when generating the item type for the query. However, the readonly item type continues to use&'w T
as the reference type. This makes it impossible to use change detection on the readonly form of mutable queries.As an example from my code:
What solution would you like?
I would like a way to inform the
QueryData
derive macro to usebevy_ecs::change_detection::Ref<'w, T>
instead of&'w T
. I believe it would be useful if we can choose between applying it to the whole struct or to individual fields, like so:Example 1: Whole struct application
Example 2: Per field application
What alternative(s) have you considered?
The only other option I can see is for me to manually implement
WorldQuery
onTextBoxQuery
, and I do not wish to manually implementWorldQuery
due to how brittle it is.The text was updated successfully, but these errors were encountered: