Feel  3.16
The best way to improve your game's feel and make it extra juicy
MoreMountains.Tools.MMSerializableDictionary< TKey, TValue > Class Template Reference

A serializable dictionary implementation, as Unity still can't serialize Dictionaries natively More...

Inheritance diagram for MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >:

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>()
 

Detailed Description

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) { } }

Template Parameters
TKey
TValue

Constructor & Destructor Documentation

◆ MMSerializableDictionary() [1/2]

◆ MMSerializableDictionary() [2/2]

MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.MMSerializableDictionary ( SerializationInfo  info,
StreamingContext  context 
)

Member Function Documentation

◆ OnAfterDeserialize()

void MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.OnAfterDeserialize ( )

Loads our two lists to our dictionary

Exceptions
Exception

◆ OnBeforeSerialize()

void MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >.OnBeforeSerialize ( )

We save the dictionary to our two lists

Member Data Documentation

◆ _keys

List<TKey> MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >._keys = new List<TKey>()
protected

◆ _values

List<TValue> MoreMountains.Tools.MMSerializableDictionary< TKey, TValue >._values = new List<TValue>()
protected

The documentation for this class was generated from the following file: