1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
3
4
using UnityEngine ;
4
5
5
6
@@ -42,25 +43,25 @@ public void OnAfterDeserialize()
42
43
}
43
44
44
45
[ Serializable ]
45
- public class ArrayContainer < T >
46
+ public class ArrayContainer
46
47
{
47
48
[ SerializeField ]
48
- public T [ ] Values = new T [ 0 ] ;
49
+ public object [ ] Values = new object [ 0 ] ;
49
50
}
50
51
51
52
[ Serializable ]
52
53
public class SerializableNestedDictionary < TKey , TValue > : Dictionary < TKey , Dictionary < TKey , TValue > > , ISerializationCallbackReceiver
53
54
{
54
55
[ SerializeField ] private TKey [ ] keys = new TKey [ 0 ] ;
55
- [ SerializeField ] private ArrayContainer < TKey > [ ] subKeys = new ArrayContainer < TKey > [ 0 ] ;
56
- [ SerializeField ] private ArrayContainer < TValue > [ ] subKeyValues = new ArrayContainer < TValue > [ 0 ] ;
56
+ [ SerializeField ] private ArrayContainer [ ] subKeys = new ArrayContainer [ 0 ] ;
57
+ [ SerializeField ] private ArrayContainer [ ] subKeyValues = new ArrayContainer [ 0 ] ;
57
58
58
59
// save the dictionary to lists
59
60
public void OnBeforeSerialize ( )
60
61
{
61
62
var keyList = new List < TKey > ( ) ;
62
- var subKeysList = new List < ArrayContainer < TKey > > ( ) ;
63
- var subKeysValuesList = new List < ArrayContainer < TValue > > ( ) ;
63
+ var subKeysList = new List < ArrayContainer > ( ) ;
64
+ var subKeysValuesList = new List < ArrayContainer > ( ) ;
64
65
65
66
foreach ( var pair in this )
66
67
{
@@ -77,8 +78,8 @@ public void OnBeforeSerialize()
77
78
serializeSubKeyValues . Add ( subPair . Value ) ;
78
79
}
79
80
80
- subKeysList . Add ( new ArrayContainer < TKey > { Values = serializeSubKeys . ToArray ( ) } ) ;
81
- subKeysValuesList . Add ( new ArrayContainer < TValue > { Values = serializeSubKeyValues . ToArray ( ) } ) ;
81
+ subKeysList . Add ( new ArrayContainer { Values = serializeSubKeys . Cast < object > ( ) . ToArray ( ) } ) ;
82
+ subKeysValuesList . Add ( new ArrayContainer { Values = serializeSubKeyValues . Cast < object > ( ) . ToArray ( ) } ) ;
82
83
}
83
84
84
85
keys = keyList . ToArray ( ) ;
0 commit comments