-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some missing reflect attributes (#14259)
# 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 ---
- Loading branch information
Showing
3 changed files
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters