Meta-issue for improving reflect-deserialized asset loading #15518
Labels
A-Assets
Load files from disk to use for things like images, models, and sounds
A-Reflection
Runtime information about types
C-Tracking-Issue
An issue that collects information about a broad development initiative
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
Uh oh!
There was an error while loading. Please reload this page.
This is a meta-issue for tracking the progress of improving how reflect-deserialized assets get loaded. This is a cross-cutting concern between both reflection and assets.
The motivating use case comes from
bevy_animation_graph
, where we deserializeAnimationGraph
s from RON files. This looks like:The two important things here are:
AnimationNode
stores a type-erasedNodeLike
AnimationClipNode
, and other node types, may store asset handlesHowever, it's currently very annoying to write code to deserialize and load this asset properly. Why?
AnimationNode
can't deriveReflect
becauseBox<dyn NodeLike>
isn'tReflect
bevy_reflect: AddReflectBox
to remotely reflectBox
#14776Box
and other wrapper types #15532impl Reflect for AnimationNode
ty
field, and deserializeinner
based on theTypeRegistration
we look upDeserializeFromRegistry
DeserializeWithRegistry
andSerializeWithRegistry
#8611Handle<T>
is deserialized, it gets set toHandle::default
which is uselessAssetLoader::load
call, we get aLoadContext
- we should use that to actually kick off a load for this asset handle when we encounter itReflectDeserializerProcessor
#15482&mut LoadContext
which we only get inside the asset processor. It doesn't exist in theTypeRegistry
used byDeserializeFromRegistry
.LoadContext
/NestedLoader
, we can't load a dynamic-typed asset (since we're using reflection, we do know theT
in theHandle<T>
, but only at runtime - i.e. only itsTypeId
)NestedLoader
API #15509ReflectDeserializerProcessor
which accepts aLoadContext
and does the two above steps for youYou have to write boilerplateDeserializeSeed
code for custom deserialization of anAnimationNode
because of thatty
Honestly not sure what to do for this. The customDeserializeSeed
actually isn't too bad compared to the rest of the boilerplate that you have to write, but I'm sure there is a better way to do this.DeserializeFromRegistry
from bevy_reflect: AddDeserializeWithRegistry
andSerializeWithRegistry
#8611Handle<T>
s as just string asset pathsReflectSerializerProcessor
#15548If these issues are solved, we have a much more powerful way to easily define these kinds of complex assets which depend on other assets, and that also use reflection to deserialize values of unknown types.
Once these are resolved, I would like to write an example which deserializes an asset in this reflective way, showing off the automatic recursive
Handle
loading, and deserializing type-erasedBox<dyn Reflect>
s.The text was updated successfully, but these errors were encountered: