bevy/crates
davier 06d9384447 Add FromReflect trait to convert dynamic types to concrete types (#1395)
Dynamic types (`DynamicStruct`, `DynamicTupleStruct`, `DynamicTuple`, `DynamicList` and `DynamicMap`) are used when deserializing scenes, but currently they can only be applied to existing concrete types. This leads to issues when trying to spawn non trivial deserialized scene.
For components, the issue is avoided by requiring that reflected components implement ~~`FromResources`~~ `FromWorld` (or `Default`). When spawning, a new concrete type is created that way, and the dynamic type is applied to it. Unfortunately, some components don't have any valid implementation of these traits.
In addition, any `Vec` or `HashMap` inside a component will panic when a dynamic type is pushed into it (for instance, `Text` panics when adding a text section).

To solve this issue, this PR adds the `FromReflect` trait that creates a concrete type from a dynamic type that represent it, derives the trait alongside the `Reflect` trait, drops the ~~`FromResources`~~ `FromWorld` requirement on reflected components, ~~and enables reflection for UI and Text bundles~~. It also adds the requirement that fields ignored with `#[reflect(ignore)]` implement `Default`, since we need to initialize them somehow.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-12-26 18:49:01 +00:00
..
bevy_app make sub_app return an &App and add sub_app_mut() -> &mut App (#3309) 2021-12-24 06:57:30 +00:00
bevy_asset Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00
bevy_audio Remove wasm audio feature flag for 2021 (#3000) 2021-11-11 01:17:38 +00:00
bevy_core Rename fixed timestep state and add a test (#3260) 2021-12-12 21:26:40 +00:00
bevy_core_pipeline make sub_app return an &App and add sub_app_mut() -> &mut App (#3309) 2021-12-24 06:57:30 +00:00
bevy_crevice Prepare crevice for vendored release (#3394) 2021-12-23 22:49:12 +00:00
bevy_derive Remove vestigial derives (#3343) 2021-12-18 00:09:24 +00:00
bevy_diagnostic Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_dylib Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_dynamic_plugin Update to edition 2021 on master (#3028) 2021-10-27 00:12:14 +00:00
bevy_ecs Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00
bevy_ecs_compile_fail_tests Fix clippy lints for 1.57 (#3238) 2021-12-02 23:40:37 +00:00
bevy_gilrs enable wasm-bindgen feature on gilrs (#3420) 2021-12-23 19:19:14 +00:00
bevy_gltf Only bevy_render should depend directly on wgpu (#3393) 2021-12-20 20:50:52 +00:00
bevy_input Add documentation and tests to AxisSettings (#3303) 2021-12-18 20:00:18 +00:00
bevy_internal enable Webgl2 optimisation in pbr under feature (#3291) 2021-12-22 20:59:48 +00:00
bevy_log Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_macro_utils Prepare crevice for vendored release (#3394) 2021-12-23 22:49:12 +00:00
bevy_math Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
bevy_pbr remove some mut in queries (#3437) 2021-12-26 05:39:46 +00:00
bevy_reflect Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00
bevy_render Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00
bevy_scene fix parenting of scenes (#2410) 2021-12-24 06:57:28 +00:00
bevy_sprite remove some mut in queries (#3437) 2021-12-26 05:39:46 +00:00
bevy_tasks Add readme as docs to relevant crates. (#2575) 2021-12-18 22:59:55 +00:00
bevy_text Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00
bevy_transform fix parenting of scenes (#2410) 2021-12-24 06:57:28 +00:00
bevy_ui remove some mut in queries (#3437) 2021-12-26 05:39:46 +00:00
bevy_utils Merge New Renderer 2021-11-22 23:57:42 -08:00
bevy_window Added set_cursor_icon(...) to Window (#3395) 2021-12-20 22:04:45 +00:00
bevy_winit Added set_cursor_icon(...) to Window (#3395) 2021-12-20 22:04:45 +00:00