Corgi Engine
v9.2
|
A serializable dictionary implementation, as Unity still can't serialize Dictionaries natively More...
Public Member Functions | |
MMSerializableDictionary () | |
MMSerializableDictionary (SerializationInfo info, StreamingContext context) | |
void | OnBeforeSerialize () |
We save the dictionary to our two lists More... | |
void | OnAfterDeserialize () |
Loads our two lists to our dictionary More... | |
Protected Attributes | |
List< TKey > | _keys = new List<TKey>() |
List< TValue > | _values = new List<TValue>() |
A serializable dictionary implementation, as Unity still can't serialize Dictionaries natively
How to use :
For each type of dictionary you want to serialize, create a serializable class that inherits from MMSerializableDictionary, and override the constructor and the SerializationInfo constructor, like so (here with a string/int Dictionary) :
[Serializable] public class DictionaryStringInt : MMSerializableDictionary<string, int> { public DictionaryStringInt() : base() { } protected DictionaryStringInt(SerializationInfo info, StreamingContext context) : base(info, context) { } }
TKey | |
TValue |
MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.MMSerializableDictionary | ( | ) |
MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.MMSerializableDictionary | ( | SerializationInfo | info, |
StreamingContext | context | ||
) |
void MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.OnAfterDeserialize | ( | ) |
Loads our two lists to our dictionary
Exception |
void MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.OnBeforeSerialize | ( | ) |
We save the dictionary to our two lists
|
protected |
|
protected |