bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Reflect everything by default & make it opt out

Open iiYese opened this issue 10 months ago • 3 comments

What problem does this solve or what need does it fill?

It's hard to remember everything you need to reflect on & it's quite verbose to do so.

What solution would you like?

Make derives for Component, Resource, State, Asset, Event also derive Reflect with a #[no_reflect] attribute to opt out.

What alternative(s) have you considered?

Manually adding reflect to everything.

iiYese avatar Apr 26 '24 22:04 iiYese

We could also add a real trait bound to all of these types. This would be more intrusive and limiting and worsen compile times, but would arguably be more idiomatic.

I think that implicitly doubling up on the derives is a better solution though.

alice-i-cecile avatar Apr 26 '24 23:04 alice-i-cecile

Note that this would make those derives incompatible with each other, as they would generate multiple Reflect impls. I've seen some people derive both Component and Resource for a given type, so this might not be ideal.

As an alternative: is it strictly necessary for them to derive Reflect? Or could they just register something like ReflectComponent in the TypeRegistry, internally using some kind of remote reflect to sidestep not knowing whether Reflect is implemented or not?

SkiFire13 avatar Apr 27 '24 08:04 SkiFire13

That sounds better

iiYese avatar Apr 27 '24 14:04 iiYese