@@ -22,7 +22,6 @@ public class InteractiveList : InteractiveValue, ICellPoolDataSource<CacheListEn
22
22
public override bool CanWrite => base . CanWrite && RefIList != null && ! RefIList . IsReadOnly ;
23
23
24
24
public Type EntryType ;
25
- //public IEnumerable RefIEnumerable;
26
25
public IList RefIList ;
27
26
28
27
public int ItemCount => values . Count ;
@@ -49,7 +48,6 @@ public override void ReleaseFromOwner()
49
48
50
49
private void ClearAndRelease ( )
51
50
{
52
- //RefIEnumerable = null;
53
51
RefIList = null ;
54
52
values . Clear ( ) ;
55
53
@@ -94,50 +92,53 @@ private void CacheEntries(object value)
94
92
{
95
93
RefIList = value as IList ;
96
94
97
- IEnumerator enumerator = ( value as IEnumerable ) . GetEnumerator ( ) ;
98
-
99
- //if (value is IEnumerable enumerable)
100
- // enumerator = enumerable.GetEnumerator();
101
- //else
102
- // enumerator = Il2CppReflection.EnumerateCppList(value);
103
-
104
95
values . Clear ( ) ;
105
96
int idx = 0 ;
106
- while ( enumerator . MoveNext ( ) )
107
- {
108
- var entry = enumerator . Current ;
109
97
110
- values . Add ( entry ) ;
98
+ if ( ReflectionUtility . TryGetEnumerator ( value , out IEnumerator enumerator ) )
99
+ {
100
+ NotSupportedLabel . gameObject . SetActive ( false ) ;
111
101
112
- // If list count increased, create new cache entries
113
- CacheListEntry cache ;
114
- if ( idx >= cachedEntries . Count )
102
+ while ( enumerator . MoveNext ( ) )
115
103
{
116
- cache = new CacheListEntry ( ) ;
117
- cache . SetListOwner ( this , idx ) ;
118
- cachedEntries . Add ( cache ) ;
104
+ var entry = enumerator . Current ;
105
+
106
+ values . Add ( entry ) ;
107
+
108
+ // If list count increased, create new cache entries
109
+ CacheListEntry cache ;
110
+ if ( idx >= cachedEntries . Count )
111
+ {
112
+ cache = new CacheListEntry ( ) ;
113
+ cache . SetListOwner ( this , idx ) ;
114
+ cachedEntries . Add ( cache ) ;
115
+ }
116
+ else
117
+ cache = cachedEntries [ idx ] ;
118
+
119
+ cache . SetFallbackType ( this . EntryType ) ;
120
+ cache . SetValueFromSource ( entry ) ;
121
+ idx ++ ;
119
122
}
120
- else
121
- cache = cachedEntries [ idx ] ;
122
-
123
- cache . SetFallbackType ( this . EntryType ) ;
124
- cache . SetValueFromSource ( entry ) ;
125
- idx ++ ;
126
- }
127
123
128
- // Remove excess cached entries if list count decreased
129
- if ( cachedEntries . Count > values . Count )
130
- {
131
- for ( int i = cachedEntries . Count - 1 ; i >= values . Count ; i -- )
124
+ // Remove excess cached entries if list count decreased
125
+ if ( cachedEntries . Count > values . Count )
132
126
{
133
- var cache = cachedEntries [ i ] ;
134
- if ( cache . CellView != null )
135
- cache . UnlinkFromView ( ) ;
136
-
137
- cache . ReleasePooledObjects ( ) ;
138
- cachedEntries . RemoveAt ( i ) ;
127
+ for ( int i = cachedEntries . Count - 1 ; i >= values . Count ; i -- )
128
+ {
129
+ var cache = cachedEntries [ i ] ;
130
+ if ( cache . CellView != null )
131
+ cache . UnlinkFromView ( ) ;
132
+
133
+ cache . ReleasePooledObjects ( ) ;
134
+ cachedEntries . RemoveAt ( i ) ;
135
+ }
139
136
}
140
137
}
138
+ else
139
+ {
140
+ NotSupportedLabel . gameObject . SetActive ( true ) ;
141
+ }
141
142
}
142
143
143
144
// Setting the value of an index to the list
@@ -185,6 +186,8 @@ public void SetCell(CacheListEntryCell cell, int index)
185
186
186
187
private LayoutElement scrollLayout ;
187
188
189
+ private Text NotSupportedLabel ;
190
+
188
191
public override GameObject CreateContent ( GameObject parent )
189
192
{
190
193
UIRoot = UIFactory . CreateVerticalGroup ( parent , "InteractiveList" , true , true , true , true , 6 , new Vector4 ( 10 , 3 , 15 , 4 ) ,
@@ -205,6 +208,13 @@ public override GameObject CreateContent(GameObject parent)
205
208
ListScrollPool . Initialize ( this , SetLayout ) ;
206
209
scrollLayout = scrollObj . GetComponent < LayoutElement > ( ) ;
207
210
211
+ NotSupportedLabel = UIFactory . CreateLabel ( ListScrollPool . Content . gameObject , "NotSupportedMessage" ,
212
+ "The IEnumerable failed to enumerate. This is likely due to an issue with Unhollowed interfaces." ,
213
+ TextAnchor . MiddleLeft , Color . red ) ;
214
+
215
+ UIFactory . SetLayoutElement ( NotSupportedLabel . gameObject , minHeight : 25 , flexibleWidth : 9999 ) ;
216
+ NotSupportedLabel . gameObject . SetActive ( false ) ;
217
+
208
218
return UIRoot ;
209
219
}
210
220
}
0 commit comments