bevy/crates/bevy_reflect/src
Gino Valente 19fc1f1ed2 bevy_reflect: Fix DynamicScene not respecting component registrations during serialization (#6288)
# Objective

When running the scene example, you might notice we end up printing out the following:
```ron
// ...
{
  "scene::ComponentB": (
    value: "hello",
    _time_since_startup: (
      secs: 0,
      nanos: 0,
    ),
  ),
},
// ...
```

We should not be printing out `_time_since_startup` as the field is marked with `#[reflect(skip_serializing)]`:

```rust
#[derive(Component, Reflect)]
#[reflect(Component)]
struct ComponentB {
  pub value: String,
  #[reflect(skip_serializing)]
  pub _time_since_startup: Duration,
}
```

This is because when we create the `DynamicScene`, we end up calling `Reflect::clone_value`:

82126697ee/crates/bevy_scene/src/dynamic_scene_builder.rs (L114-L114)

This results in non-Value types being cloned into Dynamic types, which means the `TypeId` returned from `reflected_value.type_id()` is not the same as the original component's. 

And this meant we were not able to locate the correct `TypeRegistration`.

## Solution

Use `TypeInfo::type_id()` instead of calling `Any::type_id()` on the value directly.

---

## Changelog

* Fix a bug introduced in `0.9.0-dev` where scenes disregarded component's type registrations
2022-10-24 14:53:12 +00:00
..
enums bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
impls Impl Reflect for PathBuf and OsString (#6193) 2022-10-08 17:02:21 +00:00
serde bevy_reflect: Fix DynamicScene not respecting component registrations during serialization (#6288) 2022-10-24 14:53:12 +00:00
array.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
fields.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
lib.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
list.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
map.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
path.rs Make arrays behave like lists in reflection (#5987) 2022-09-27 18:11:38 +00:00
reflect.rs bevy_reflect: Update Reflection documentation (#5841) 2022-09-02 16:17:45 +00:00
std_traits.rs add #[reflect(Default)] to create default value for reflected types (#3733) 2022-05-03 19:20:13 +00:00
struct_trait.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
tuple_struct.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
tuple.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
type_info.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
type_registry.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
type_uuid.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00
utility.rs bevy_reflect: Improve serialization format even more (#5723) 2022-09-20 19:38:18 +00:00