-
-
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
Updated World
, UnsafeWorldCell
Resource
methods to use Res
, ResMut
#9940
Updated World
, UnsafeWorldCell
Resource
methods to use Res
, ResMut
#9940
Conversation
I don't see much reason to change |
Between that, and this comment from @cart, I'm going to switch this PR to draft and make some fairly major changes. |
…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>
Going to close this out since we're likely going to move in the direction described in #11825 |
Objective
Solution
UnsafeWorldCell
Resource
methods to return eitherRes
orResMut
where appropriate, usingget_resource_with_ticks
to obtain the relevant data.World
Changelog
UnsafeWorldCell::get_resource(_mut)
to returnRes/ResMut
World::(get_)resource(_mut)
to returnRes
/ResMut
World::resource_scope
to useResMut
Migration Guide
Simply use
into_inner()
to retrieve the inner reference for&R
being replaced withRes
, andinto
forMut
andResMut
.