[WIP] Serializable Collections for Unity

You can now find a working version of Serializable Collections for Unity on GitHub:

One of the great things about .NET is that it comes with a bunch of powerful collections, and one of the things that’s most annoyed me about Unity over the years is that you can only serialize one of these collections. It just cuts off all kinds of possibilities for improving performance and making things easier. I’ve also been on a kick of messing with the editor, so I got it into my head to bring these collections to Unity. Then, because I couldn’t leave well enough alone, I implemented it using a ReorderableList, added a page system, and settings that can be applied globally or per list.

The collections all behave exactly as the MSDN documentation for those classes state that they should; each one has the same methods and uses the same interfaces as its .NET equivalent, and has the same performance characteristics. Every collection in the System.Collections.Generic namespace is here, even the List class, so you can use the custom property drawer instead of the way a List is normally drawn in the inspector.

Due to Unity’s serialization restrictions, you do have to create a custom class, as normal when using generics:

[Serializable]
public class SortedStringList : SortedList<int, string> { }

If you’re wondering how the different collections matter in performance, and when you should use each one, here’s a handy guide on the differences and uses of each collection.

1 Like

After a lot of work, I’ve got an early version up on my GitHub at GitHub - DameonL/Serializable-Collections-For-Unity: Wrappers for all the .NET collections in System.Collections.Generic that allow them to be used with the Unity editor and its serialization.
Any suggestions or feedback is welcome! Once I’m relatively sure I have any major bugs identified and fixed, I’ll be submitting it to the Asset Store.