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.
  2. Dismiss Notice

4.5.2 : Update notes weirdness...

Discussion in 'Scripting' started by LightStriker, Jul 10, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    But... Unity does not serialize generic types with the exception of List<T>.

    So what array of generic?

    (Also, it's serializing, not serialising...)
     
  2. Foam

    Foam

    Joined:
    Jun 13, 2012
    Posts:
    322
    Array and List are not the same thing.
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Well, duh!

    So what means "Array of generic types" in Unity's context?

    List<T>[]? We know Unity doesn't support nested collection. We also know it support only 1 generic type; List<T>.
     
    IvanAuda likes this.
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Could it be referring to the ArrayList (UnityScript's Array) class?
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    You can't put a generic in an ArrayList... Unless I missed something, Unity doesn't serialize that.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    It fixed a case like this:

    Code (csharp):
    1.  
    2. [Serializable]
    3. public class Base<T>
    4. {
    5.     public T something;
    6. }
    7.  
    8. [Serializable]
    9. public class Derived : Base<int>
    10. {
    11. }
    12.  
    13. public class Script : MonoBehaviour
    14. {
    15.     public Derived[] Items;
    16. }
    17.  
     
    Last edited: Jul 10, 2014
    GarthSmith and StarManta like this.
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Not <generic>, no, but everything in an ArrayList is not typed, so whoever wrote that note may have meant that by "generic". (And as I haven't used ArrayLists for about 4 years for obvious reasons, I can't speak to whether or not Unity can serialize them. Maybe now it can?)
     
  8. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    How odd... I don't remember ever having issue saving list of non-generic deriving from generic. I guess it was some kind of edge-case.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    I believe the issue was only with regular arrays, not lists. I could be wrong, though.
     
    GarthSmith likes this.