Skip to content

Serialization through Bevy's type registry#534

Merged
djeedai merged 20 commits into
mainfrom
u/typereg
Jun 6, 2026
Merged

Serialization through Bevy's type registry#534
djeedai merged 20 commits into
mainfrom
u/typereg

Conversation

@djeedai

@djeedai djeedai commented Jun 6, 2026

Copy link
Copy Markdown
Owner

This change transitions from the typetag dependency to using Bevy's own
built-in TypeRegistry to serialize and deserialize Hanabi's EffectAsset (*.effect).

This solves a long-standing issue where modifiers couldn't be serialized easily,
and user-provided modifiers were ignored for serialization. With the use of
Bevy's own type registry, all built-in and user modifiers are treated equally,
as long as they are registered via register_reflect_modifier(). All built-in modifiers
are automatically registered by the HanabiPlugin.

That registration allows leveraging the new ReflectModifier type data, which
provides a factory function to create a concrete modifier type instance. This is
used during deserialization to instantiate the actual modifier object. This works
around the lack of reflection/serialization support for Box<dyn Trait>.

This change has a few knock-on effects on other parts of Hanabi:

  • EffectAsset::mesh is now an Option<AssetPath<'static>> referencing the
    mesh, if any, used to render particles. That path is now also serialized.
  • At runtime, the new EffectMesh component can override this asset mesh.

With this, EffectAsset is now entirely serializable. This doesn't solve the entire
asset story, as some additional items are still missing (notably, textures). But
this should greatly improve the value proposition for loading Hanabi effects
from assets on disk, rather than generating effects in code.

@djeedai djeedai added C - enhancement New feature or request A - modifiers Change related to modifiers C - breaking change A breaking API or behavior change A - components Change related to an ECS component D - complex Complex change A - serde Serialization and deserialization labels Jun 6, 2026
@djeedai djeedai merged commit c34b95a into main Jun 6, 2026
18 of 19 checks passed
@djeedai djeedai deleted the u/typereg branch June 6, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A - components Change related to an ECS component A - modifiers Change related to modifiers A - serde Serialization and deserialization C - breaking change A breaking API or behavior change C - enhancement New feature or request D - complex Complex change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant