blob: f47a8923a0f57b48f9bbc7032e44efd61b8544da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SerializableDictionaryExample : MonoBehaviour {
// The dictionaries can be accessed throught a property
[SerializeField]
StringStringDictionary m_stringStringDictionary;
public IDictionary<string, string> StringStringDictionary
{
get { return m_stringStringDictionary; }
set { m_stringStringDictionary.CopyFrom (value); }
}
public ObjectColorDictionary m_objectColorDictionary;
public StringColorArrayDictionary m_objectColorArrayDictionary;
void Reset ()
{
// access by property
StringStringDictionary = new Dictionary<string, string>() { {"first key", "value A"}, {"second key", "value B"}, {"third key", "value C"} };
m_objectColorDictionary = new ObjectColorDictionary() { {gameObject, Color.blue}, {this, Color.red} };
}
}
|