bevy
bevy copied to clipboard
Make `from_reflect_or_world` also try `ReflectDefault` and improve some comments and panic messages
Objective
from_reflect_or_worldis an internal utilty used in the implementations ofReflectComponentandReflectBundleto create aTgiven a&dyn Reflectby trying to useFromReflect, and if that fails it falls back toReflectFromWorld- reflecting
FromWorldis not intuitive though: often it is implicitly implemented by derivingDefaultso people might not even be aware of it. - the panic messages mentioning
ReflectFromWorldare not directly correlated to what the user would have to do (reflectFromWorld)
Solution
- Also check for
ReflectDefaultin addition toReflectFromWorld. - Change the panic messages to mention the reflected trait rather than the
Reflect*types.
Changelog
ReflectComponentandReflectBundleno longer requireT: FromReflectbut instead onlyT: Reflect.ReflectComponentandReflectBundlewill also work with types that only reflectedDefaultand notFromWorld.
Migration Guide
ReflectBundle::insertnow requires an additional&TypeRegistryparameter.