bevy/crates/bevy_reflect/src
Gino Valente 6cc01c1449 bevy_reflect: Add simple enum support to reflection paths (#6560)
# Objective

Enums are now reflectable, but are not accessible via reflection paths.

This would allow us to do things like:

```rust
#[derive(Reflect)]
struct MyStruct {
  data: MyEnum
}

#[derive(Reflect)]
struct MyEnum {
  Foo(u32, u32),
  Bar(bool)
}

let x = MyStruct {
  data: MyEnum::Foo(123),
};

assert_eq!(*x.get_path::<u32>("data.1").unwrap(), 123);
```

## Solution

Added support for enums in reflection paths.

##### Note
This uses a simple approach of just getting the field with the given accessor. It does not do matching or anything else to ensure the enum is the intended variant. This means that the variant must be known ahead of time or matched outside the reflection path (i.e. path to variant, perform manual match, and continue pathing).

---

## Changelog

- Added support for enums in reflection paths
2023-01-11 16:46:27 +00:00
..
enums bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
impls bevy_reflect: Simplify take-or-else-from_reflect operation (#6566) 2023-01-11 16:25:37 +00:00
serde Fix beta clippy lints (#7154) 2023-01-11 09:51:22 +00:00
array.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
fields.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
from_reflect.rs bevy_reflect: Simplify take-or-else-from_reflect operation (#6566) 2023-01-11 16:25:37 +00:00
lib.rs bevy_reflect: Add ReflectFromReflect (v2) (#6245) 2022-12-11 17:52:48 +00:00
list.rs reflect: add insert and remove methods to List (#7063) 2023-01-09 19:47:07 +00:00
map.rs Add remove method to Map reflection trait. (#6564) 2022-11-14 21:03:39 +00:00
path.rs bevy_reflect: Add simple enum support to reflection paths (#6560) 2023-01-11 16:46:27 +00:00
reflect.rs bevy_reflect: Add ReflectFromReflect (v2) (#6245) 2022-12-11 17:52:48 +00:00
std_traits.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
struct_trait.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
tuple.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
tuple_struct.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
type_info.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
type_registry.rs Add safe constructors for untyped pointers Ptr and PtrMut (#6539) 2022-11-14 22:53:50 +00:00
type_uuid.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00
utility.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00