Advertisement Jump to content
Sign in to follow this  

Serializing Angelscript classes

This topic is 1799 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



How would I go about serializing and deserializing Angelscript classes into a human readable format (preferably XML)? I've looked at the boost:serialization library, and it seems to require that functions be written specially for serializing each class. Is it possible to automatically serialize and deserialize classes without already knowing specifically what the members of each class are? If it requires a little diving into the source code I'm down for that, but I'd like to have the most elegant solution possible.


Thanks in advance,





I've come up with an idea for how to achieve this, though it wouldn't really be serialization in the strictest sense, but close enough for what I need. I'll report back if I get something working.

Edited by Salty Boyscouts

Share this post

Link to post
Share on other sites

Oh, I forgot to mention how you might go about to deserialize a script object from an XML file.


To deserialize the object you first need to create the object instance while bypassing the class constructor (so that it doesn't cause any unwanted side-effects). You can do this by calling the engine's CreateUninitializedScriptObject method. Once you've done that you use the methods from the Reflection article mentioned before to enumerate and set the value of each of the object's properties.


The biggest problem you'll face when implementing the serialization is to determine how to deal with reference to other objects, e.g. should the other object also be fully serialized, or should you just serialize a token that will let you find the same reference when deserializing? That will depend very much on the structure of your application, so it can't be answered uniquely.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!