0
public class ExampleClass
{
    public GameObject a;
    public SerializableDictionary<int, ExampleClass2> b = new SerializableDictionary<int, ExampleClass2>()
    public int c;
    protected string d;
    protected XYZ e;
}

ExampleClass exampleClass = getExampleClass();

string exampleClassData= JsonUtility.ToJson(exampleClass );


string exampleClassDataJsonDotNet = JsonConvert.SerializeObject(exampleClass );

For the above code while serialization if I use JsonUtility.ToJson its missing to serialize the SerializableDictionary<int , ExampleClass2> b , its serializing protected because I added [SerializeField] and ExampleClass2 is also Serialization supported.

If I used JsonConvert.SerializeObject its working great will all types but unable to Serialize GameObject

Are there any solution to make it work in any of ways?

djkpA
  • 1,224
  • 2
  • 27
  • 57
  • So `b` isn't serialising - is that the issue? Does it work if the key is `string` rather than `int`? – mjwills Sep 08 '17 at 13:29
  • haven`t tested it because ExampleClass is 3rd party asset and it needs to be like that. So I might need something to make above work – djkpA Sep 08 '17 at 13:33
  • You can't serialize GameObject. For dictionary, use thirdparty(Newton) API – Programmer Sep 08 '17 at 16:17
  • but while using JsonUtility gameObject is serialized as `"gameObject":{"instanceID":844016},"` – djkpA Sep 09 '17 at 04:46

0 Answers0