22{
33 using System ;
44 using System . Collections . Generic ;
5- using System . Runtime . Serialization ;
5+ using Sirenix . OdinInspector ;
66 using TypeReferences ;
7+ using UnityEditor ;
78 using UnityEngine ;
89
910 public class GenericDerivativesDatabase :
1011 SingletonScriptableObject < GenericDerivativesDatabase > ,
11- ISerializationCallbackReceiver ,
12- IDeserializationCallback ,
13- ISerializable
12+ ISerializationCallbackReceiver
1413 {
1514 public const string Template = "namespace GenericScriptableObjectsTypes { public class " +
1615 "Generic_#TYPE_NAME : GenericScriptableObjects.Generic<#TYPE> { } }" ;
1716
1817 private readonly Dictionary < TypeReference , TypeReference > _dict =
1918 new Dictionary < TypeReference , TypeReference > ( new TypeReferenceComparer ( ) ) ;
2019
21- [ SerializeField , TypeOptions ( ExcludeNone = true , ShortName = true ) ]
20+ [ SerializeField ]
21+ // [TypeOptions(ExcludeNone = true, ShortName = true)]
2222 // [HideInInspector] // TODO: hide fields
2323 private TypeReference [ ] _keys ;
2424
25- [ SerializeField , Inherits ( typeof ( Generic < > ) , ExcludeNone = true , ShortName = true , ExpandAllFolders = true ) ]
25+ [ SerializeField ]
26+ // [Inherits(typeof(Generic<>), ExcludeNone = true, ShortName = true, ExpandAllFolders = true)]
2627 // [HideInInspector]
2728 private TypeReference [ ] _values ;
2829
2930 public TypeReference this [ TypeReference key ]
3031 {
3132 get => _dict [ key ] ;
32- set => _dict [ key ] = value ;
33+ set
34+ {
35+ _dict [ key ] = value ;
36+ EditorUtility . SetDirty ( this ) ;
37+ }
3338 }
3439
3540 public static void Add ( Type key , Type value ) =>
3641 Instance . _dict . Add ( new TypeReference ( key ) , new TypeReference ( value ) ) ;
3742
38- public static bool ContainsKey ( Type key ) => Instance . _dict . ContainsKey ( new TypeReference ( key ) ) ;
43+ public static bool ContainsKey ( Type key )
44+ {
45+ bool containsKey = Instance . _dict . ContainsKey ( new TypeReference ( key ) ) ;
46+ EditorUtility . SetDirty ( Instance ) ;
47+ return containsKey ;
48+ }
3949
4050 public static bool TryGetValue ( TypeReference key , out TypeReference value ) =>
4151 Instance . _dict . TryGetValue ( key , out value ) ;
@@ -80,10 +90,5 @@ public void OnBeforeSerialize()
8090 ++ keysIndex ;
8191 }
8292 }
83-
84- public void OnDeserialization ( object sender ) => _dict . OnDeserialization ( sender ) ;
85-
86- public void GetObjectData ( SerializationInfo info , StreamingContext context ) =>
87- _dict . GetObjectData ( info , context ) ;
8893 }
8994}
0 commit comments