Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Cannot Serialize lists or arrays of generic types

Discussion in '2020.1 Beta' started by jasonatkaruna, Nov 16, 2019.

  1. jasonatkaruna


    Feb 26, 2019
    Not sure if this is a known issue, or if it's intended, but as of now, you cannot serialize lists or arrays of generic types.

    The following won't serialize:

    Code (CSharp):
    1. [Serializable]
    2. public class Wrapper<T>
    3. {
    4.     public T wrappedValue;
    5. }
    7. public class MyMonoBehaviour : MonoBehaviour
    8. {
    9.     public Wrapper<int>[] wrappers; // this won't serialize
    10.     public Wrapper<int> singleWrapper; // this serializes fine
    11.     public int[] ints; // this serializes fine
    12. }