mirror of
https://github.com/bevyengine/bevy
synced 2025-02-27 04:47:14 +00:00
# Objective - Some types are missing reflection attributes, which means we can't use them in scene serialization etc. - Effected types - `BorderRadius` - `AnimationTransitions` - `OnAdd` - `OnInsert` - `OnRemove` - My use-case for `OnAdd` etc to derive reflect is 'Serializable Observer Components'. Add the component, save the scene, then the observer is re-added on scene load. ```rust #[derive(Reflect)] struct MySerializeableObserver<T: Event>(#[reflect(ignore)]PhantomData<T>); impl<T: Event> Component for MySerializeableObserver<T> { const STORAGE_TYPE: StorageType = StorageType::Table; fn register_component_hooks(hooks: &mut ComponentHooks) { hooks.on_add(|mut world, entity, _| { world .commands() .entity(entity) .observe(|_trigger: Trigger<T>| { println!("it triggered etc."); }); }); } } ``` ## Solution - Add the missing traits --- |
||
---|---|---|
.. | ||
entity | ||
event | ||
identifier | ||
observer | ||
query | ||
reflect | ||
schedule | ||
storage | ||
system | ||
world | ||
archetype.rs | ||
batching.rs | ||
bundle.rs | ||
change_detection.rs | ||
component.rs | ||
intern.rs | ||
label.rs | ||
lib.rs | ||
removal_detection.rs | ||
traversal.rs |