bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Get Ref<Component> from a query by entity

Open ThomasAlban opened this issue 2 years ago • 3 comments

Currently, as far as I know, there's no API for getting a Ref<Component> from a query.get(entity).unwrap() without changing the query to be a Query<Ref<Component>> or having to do Ref::from(query.get_mut(entity)). Would be nice if this was added!

ThomasAlban avatar Jan 24 '24 23:01 ThomasAlban

We'll want this on Query, QueryState, EntityRef, EntityMut, and probably EntityWorldMut 🙃

Should be quite approachable, but you'll need some bravery exploring the ECS!

alice-i-cecile avatar Jan 24 '24 23:01 alice-i-cecile

I'd like to try if that's ok.

Adamkob12 avatar Jan 26 '24 08:01 Adamkob12

Sounds good! Don't hesitate to open a draft PR and then ask for help :)

alice-i-cecile avatar Jan 26 '24 13:01 alice-i-cecile

As discussed in #11545, the complexity is too high here relative to the value. Maybe one day with effects.

alice-i-cecile avatar Feb 12 '24 03:02 alice-i-cecile