title: Unity/C# serializable array of multiple structs
body: <p>I'm struggling with so simple thing developing game in Unity.</p>
  
  <p>I mark my struct as Serializable. This struct has several fields, including array of custom serializable classes. </p>
  
  <pre><code>[Serializable]
  public struct GameSerialized {
      public StorageSerialized storage;
      public BankSerialized bank;
      public object[] buildings;
  }
  </code></pre>
  
  <p>After inspecting JSON output <code>JsonUtility.ToJson(new GameSerialized(game))</code> unfortunately there is nothing about buildings. Buildings array contains only serializable structs, i.g. HouseSerialized, MillSerialized etc. I think it is the problem of declaration <code>object[]</code>, because if I declare it e.g. <code>public HouseSerialized[] houses</code> they are very nicely serialized.</p>
  
  <p>I'd like to use pure language functionality, trying to avoid using custom libs. And I want to do proper architecture, so that game doesn't really know what buildings are inside, as long as they can be serialized.</p>
  
  <p>Thanks for your help.</p>