bevy/examples/2d
radiish 1efc762924
reflect: stable type path v2 (#7184)
# Objective

- Introduce a stable alternative to
[`std::any::type_name`](https://doc.rust-lang.org/std/any/fn.type_name.html).
- Rewrite of #5805 with heavy inspiration in design.
- On the path to #5830.
- Part of solving #3327.


## Solution

- Add a `TypePath` trait for static stable type path/name information.
- Add a `TypePath` derive macro.
- Add a `impl_type_path` macro for implementing internal and foreign
types in `bevy_reflect`.

---

## Changelog

- Added `TypePath` trait.
- Added `DynamicTypePath` trait and `get_type_path` method to `Reflect`.
- Added a `TypePath` derive macro.
- Added a `bevy_reflect::impl_type_path` for implementing `TypePath` on
internal and foreign types in `bevy_reflect`.
- Changed `bevy_reflect::utility::(Non)GenericTypeInfoCell` to
`(Non)GenericTypedCell<T>` which allows us to be generic over both
`TypeInfo` and `TypePath`.
- `TypePath` is now a supertrait of `Asset`, `Material` and
`Material2d`.
- `impl_reflect_struct` needs a `#[type_path = "..."]` attribute to be
specified.
- `impl_reflect_value` needs to either specify path starting with a
double colon (`::core::option::Option`) or an `in my_crate::foo`
declaration.
- Added `bevy_reflect_derive::ReflectTypePath`.
- Most uses of `Ident` in `bevy_reflect_derive` changed to use
`ReflectTypePath`.

## Migration Guide

- Implementors of `Asset`, `Material` and `Material2d` now also need to
derive `TypePath`.
- Manual implementors of `Reflect` will need to implement the new
`get_type_path` method.

## Open Questions
- [x] ~This PR currently does not migrate any usages of
`std::any::type_name` to use `bevy_reflect::TypePath` to ease the review
process. Should it?~ Migration will be left to a follow-up PR.
- [ ] This PR adds a lot of `#[derive(TypePath)]` and `T: TypePath` to
satisfy new bounds, mostly when deriving `TypeUuid`. Should we make
`TypePath` a supertrait of `TypeUuid`? [Should we remove `TypeUuid` in
favour of
`TypePath`?](2afbd85532 (r961067892))
2023-06-05 20:31:20 +00:00
..
2d_gizmos.rs Added arc_2d function for gizmos (#8448) 2023-04-21 15:34:07 +00:00
2d_shapes.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bloom_2d.rs add a default font (#8445) 2023-04-21 22:30:18 +00:00
custom_gltf_vertex_attribute.rs reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
mesh2d.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
mesh2d_manual.rs fix new clippy lints before they reach stable (#8700) 2023-05-29 07:23:50 +00:00
mesh2d_vertex_color_texture.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
move_sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
pixel_perfect.rs Explain why default_nearest is used in pixel_perfect example (#8370) 2023-04-13 17:58:06 +00:00
rotation.rs Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
sprite_flipping.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
sprite_sheet.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
text2d.rs Changed spelling linebreak_behaviour to linebreak_behavior (#8285) 2023-04-05 21:25:53 +00:00
texture_atlas.rs Remove OnUpdate system set (#8260) 2023-04-04 00:49:41 +00:00
transparency_2d.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00