Kai

I would love to have official functions in spine-c that can serialize/deserialize an AnimationState into a portable binary format. This would be very helpful for my game which requires network synchronization of animations. :rock:

Right now the AnimationState variables are hidden in an internal struct. To work around this I redefined the _Internal struct in my own code and cast the AnimationState* into the _Internal struct so I can access its fields. This is obviously hacky but it is necessary to have access to the entire state of the AnimationState object for serialization. After gaining access, the serialization of AnimationState is straightforward because the fields are all float, int, or Animation* (which can be serialized based on the animation name).

Other alternatives I could currently use would be to modify the source code of the spine-c runtime or reimplement the functionality of AnimationState in my own class. However I prefer to avoid these solutions so that I can benefit from improvements to the spine-c runtime in the future.

Ultimately, having functions specifically for serialization/deserialization means that I can send the animation over the network with little effort, and Nate can still keep the AnimationState implementation internal if he feels that is advantageous.
Kai
  • Mesajlar: 1

Nate

Normally we don't want the internal fields exposed. We could write a method that gives bytes and one that populates it from bytes, but I won't have time to do that soon. Could be a github pull request! :)
Kullanıcı avatarı
Nate

Nate
  • Mesajlar: 12032


Dön Runtimes