Issues when using Unity Serializer

Hello i’m using the 3rd part plugin “Unity Serializer” Which is available on the asset store and all people are pointing to it, my problem is that I can’t get this plugin to serialize my class, i don’t need to add the stuff in the editor … I just need Storage.serializetostring(myObject). That’s all.

So i downloaded the asset extracted it and i just imported the whydoidoit which i believe contains the necessary classes for serializing, After that i went to Visual Studio and marked the property of the class i wanted to serializable with “SerializeThis”, but when i call Storage.serializeToString(myObject) it always return a constant string, I tried to create a new class with just properties of int and string thinking that the problem might be the properties of my class (GameObject, lists …) but SerializeToString always returning the same value no matter what object is passed.

I think i should add some code snippets my C# code will be better than my English :smiley: :

TestClass.cs:

using UnityEngine;
using System.Collections;

public class TestClass : MonoBehaviour 
{

// Use this for initialization
public int score { get; set; }
public string Name { get; set; }
public string Message { get; set; }
}​

SerializationHelper.cs : this class is static and allow me to use the Unity Serializer class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Serialization;
using Assets.Scripts;

public static class StorageHelper
{
public static void SaveLevel(Level level)
{
TestClass test = new TestClass();
test.score = 10;
test.Name = "reda";
test.Message = "Hello";
var repre = Storage.SerializeToString(test);
Debug.Log(repre);
}
}​

If you guys know what’s the problem here, please share your knowledge, also am new to here so if I did a mistake I will edit it, Thanks in advance.

I haven’t really used this serializer yet, but what i can tell right away is that you’re doing something fundamentally wrong ^^. Your class is derived from MonoBehaviour. That makes this class a component. Components can’t be created with “new”. You should actually get a warning about that.