-
-
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
World::resource and allies do not return Res / ResMut smart pointers #9926
Comments
Should |
Yes, I think it should. |
Maybe not a good first issue, as getting a Resource changed/added ticks can be retrieved from |
Fully on board for making APIs consistent. But as an alternative, maybe we should add |
An additional argument for consistency here: you can get the change ticks for a resource from the World, but only when extracting it mutably. |
…ref` (#11561) # Objective It's sometimes desirable to get a `Res<T>` rather than `&T` from `World::get_resource`. Alternative to #9940, partly adresses #9926 ## Solution added additional methods to `World` and `UnsafeWorldCell` to retrieve a resource wrapped in a `Res`. - `UnsafeWorldCell::get_resource_ref` - `World::get_resource_ref` - `World::resource_ref` I can change it so `World::resource_mut` returns `ResMut` instead of `Mut` as well if that's desired, but that could also be added later in a seperate pr. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Mike <mike.hsu@gmail.com> Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
…ref` (bevyengine#11561) # Objective It's sometimes desirable to get a `Res<T>` rather than `&T` from `World::get_resource`. Alternative to bevyengine#9940, partly adresses bevyengine#9926 ## Solution added additional methods to `World` and `UnsafeWorldCell` to retrieve a resource wrapped in a `Res`. - `UnsafeWorldCell::get_resource_ref` - `World::get_resource_ref` - `World::resource_ref` I can change it so `World::resource_mut` returns `ResMut` instead of `Mut` as well if that's desired, but that could also be added later in a seperate pr. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Mike <mike.hsu@gmail.com> Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
Closing in favor of #11825 |
Bevy version
0.11
What you did
Called World::resource
What went wrong
I expected a Res or ResMut smart pointer, so I could call change detection methods and reuse code more easily.
Instead I got a & or a Mut.
The text was updated successfully, but these errors were encountered: