@@ -10,7 +10,7 @@ public static class CollectionUtility
1010 private static Dictionary < Object , Editor > itemToEditor =
1111 new Dictionary < Object , Editor > ( ) ;
1212
13- private static Dictionary < Object , bool > objectToFoldOut = new Dictionary < Object , bool > ( ) ;
13+ private static Dictionary < int , bool > objectToFoldOut = new Dictionary < int , bool > ( ) ;
1414
1515 [ MenuItem ( "Assets/Create/ScriptableObject Collection/New Collection" , false , 100 ) ]
1616 private static void CreateNewItem ( )
@@ -28,6 +28,23 @@ private static void CreateSettings()
2828 ScriptableObjectCollectionSettings . LoadOrCreateInstance < ScriptableObjectCollection > ( ) ;
2929 }
3030
31+
32+ private static int GetHasCount ( Object [ ] objects )
33+ {
34+ int hasValue = 0 ;
35+ for ( int i = 0 ; i < objects . Length ; i ++ )
36+ {
37+ Object targetObj = objects [ i ] ;
38+
39+ if ( targetObj == null )
40+ continue ;
41+
42+ hasValue += targetObj . GetHashCode ( ) ;
43+ }
44+
45+ return hasValue ;
46+ }
47+
3148 public static Editor GetOrCreateEditorForItem ( Object collectionItem )
3249 {
3350 if ( itemToEditor . TryGetValue ( collectionItem , out Editor customEditor ) )
@@ -37,28 +54,26 @@ public static Editor GetOrCreateEditorForItem(Object collectionItem)
3754 itemToEditor . Add ( collectionItem , customEditor ) ;
3855 return customEditor ;
3956 }
40-
41- public static bool IsFoldoutOpen ( Object targetObject )
57+
58+ public static bool IsFoldoutOpen ( params Object [ ] objects )
4259 {
43- if ( targetObject . IsNull ( ) )
60+ int hashCount = GetHasCount ( objects ) ;
61+
62+ if ( hashCount == 0 )
4463 return false ;
45-
46- bool value ;
47- if ( ! objectToFoldOut . TryGetValue ( targetObject , out value ) )
48- objectToFoldOut . Add ( targetObject , value ) ;
64+
65+ if ( ! objectToFoldOut . TryGetValue ( hashCount , out bool value ) )
66+ objectToFoldOut . Add ( hashCount , value ) ;
4967
5068 return value ;
5169 }
5270
53- public static void SetFoldoutOpen ( Object targetObject , bool value )
71+ public static void SetFoldoutOpen ( bool value , params Object [ ] objects )
5472 {
55- if ( ! objectToFoldOut . ContainsKey ( targetObject ) )
56- objectToFoldOut . Add ( targetObject , value ) ;
57- else
58- objectToFoldOut [ targetObject ] = value ;
59- }
73+ int hashCount = GetHasCount ( objects ) ;
6074
61-
75+ objectToFoldOut [ hashCount ] = value ;
76+ }
6277 }
6378}
6479
0 commit comments