Mapping between classes for serialization

Well, I’m working on a WebGL app that allows the user to add contents like images, sounds, 3D objects, etc… over augmented reality targets.

This app is responsible of the creation of any of the contents and later it should serialize all the contents added by the user and save them in a server to be able to reproduce them in a mobile app.

**My problem is: **
I want to save the position data of the contents that the user adds but since I’m trying to serialize the data from the scripts attached to each content (i.e. image gameobject has a image script) and those scripts inherit from Monobehavior I can’t serialize the transform data for that content.

So now I’m trying to find a solution for that issue creating separate scripts that contain only the data that will be saved (without being attached to a gameobject) and I was thinking, is there a library or something similar to Automapper in C# to map the values between the scripts when the app saves the data?

Note: I’ve also tried downloading Automapper dll and use it as a plugin but I can’t find a proper version that works with .Net Unity Subset 3.5.

Thanks in advance.

You can store the transform position rotation using json string and you can get the json for that object and you can set the position and rotation from the json.

Here is my answer:

I haven’t found a a solution trying to use Automapper so here is what I have done to fix my problem.

I have created a class (not derived from Monobehavior) for each of the contents types. These contain the serialization attributes and the properties that I need to save (not all the properties saved in the monobehavior classes attached to the gameobjects).

So with this setup, when I need to call the serialization method, I call another method that manages to create any of these “serializable” classes with the data that they need.

Thanks to @RF008 for the original idea.