Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Cannot Serialize lists or arrays of generic types

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

  1. jasonatkaruna

    jasonatkaruna

    Joined:
    Feb 26, 2019
    Posts:
    64
    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. }
    6.  
    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. }