You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 deserialize AnimationGraphs from RON files. This looks like:
Note: the difference between what we're doing here and what we're doing in the step above, is that in this step, we have access to a &mut LoadContext which we only get inside the asset processor. It doesn't exist in the TypeRegistry used by DeserializeFromRegistry.
Using the LoadContext / NestedLoader, we can't load a dynamic-typed asset (since we're using reflection, we do know the T in the Handle<T>, but only at runtime - i.e. only its TypeId)
There should be an inbuilt impl of ReflectDeserializerProcessor which accepts a LoadContext and does the two above steps for you
PR to be written
You have to write boilerplate DeserializeSeed code for custom deserialization of an AnimationNode because of that ty
Honestly not sure what to do for this. The custom DeserializeSeed 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.
If 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-erased Box<dyn Reflect>s.
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 deserializeAnimationGraphs from RON files. This looks like:The two important things here are:
AnimationNodestores a type-erasedNodeLikeAnimationClipNode, and other node types, may store asset handlesHowever, it's currently very annoying to write code to deserialize and load this asset properly. Why?
AnimationNodecan't deriveReflectbecauseBox<dyn NodeLike>isn'tReflectbevy_reflect: AddReflectBoxto remotely reflectBox#14776Boxand other wrapper types #15532impl Reflect for AnimationNodetyfield, and deserializeinnerbased on theTypeRegistrationwe look upDeserializeFromRegistryDeserializeWithRegistryandSerializeWithRegistry#8611Handle<T>is deserialized, it gets set toHandle::defaultwhich is uselessAssetLoader::loadcall, we get aLoadContext- we should use that to actually kick off a load for this asset handle when we encounter itReflectDeserializerProcessor#15482&mut LoadContextwhich we only get inside the asset processor. It doesn't exist in theTypeRegistryused byDeserializeFromRegistry.LoadContext/NestedLoader, we can't load a dynamic-typed asset (since we're using reflection, we do know theTin theHandle<T>, but only at runtime - i.e. only itsTypeId)NestedLoaderAPI #15509ReflectDeserializerProcessorwhich accepts aLoadContextand does the two above steps for youYou have to write boilerplateDeserializeSeedcode for custom deserialization of anAnimationNodebecause of thattyHonestly not sure what to do for this. The customDeserializeSeedactually 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.DeserializeFromRegistryfrom bevy_reflect: AddDeserializeWithRegistryandSerializeWithRegistry#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
Handleloading, and deserializing type-erasedBox<dyn Reflect>s.