1
1
using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
+ using System . Threading ;
4
5
using UnityEngine ;
5
6
#if CPP
6
7
using UnhollowerBaseLib ;
@@ -15,8 +16,8 @@ public class CacheDictionary : CacheObjectBase, IExpandHeight
15
16
16
17
public PageHelper Pages = new PageHelper ( ) ;
17
18
18
- private CacheObjectBase [ ] m_cachedKeys ;
19
- private CacheObjectBase [ ] m_cachedValues ;
19
+ private CacheObjectBase [ ] m_cachedKeys = new CacheObjectBase [ 0 ] ;
20
+ private CacheObjectBase [ ] m_cachedValues = new CacheObjectBase [ 0 ] ;
20
21
21
22
public Type TypeOfKeys
22
23
{
@@ -119,6 +120,11 @@ public override void UpdateValue()
119
120
120
121
base . UpdateValue ( ) ;
121
122
123
+ CacheEntries ( ) ;
124
+ }
125
+
126
+ public void CacheEntries ( )
127
+ {
122
128
// reset
123
129
IDict = null ;
124
130
@@ -190,8 +196,6 @@ public override void DrawValue(Rect window, float width)
190
196
191
197
var whitespace = CalcWhitespace ( window ) ;
192
198
193
- int count = m_cachedKeys . Length ;
194
-
195
199
if ( ! IsExpanded )
196
200
{
197
201
if ( GUILayout . Button ( "v" , new GUILayoutOption [ ] { GUILayout . Width ( 25 ) } ) )
@@ -209,6 +213,8 @@ public override void DrawValue(Rect window, float width)
209
213
210
214
var negativeWhitespace = window . width - ( whitespace + 100f ) ;
211
215
216
+ int count = m_cachedKeys . Length ;
217
+
212
218
GUI . skin . button . alignment = TextAnchor . MiddleLeft ;
213
219
string btnLabel = $ "[{ count } ] <color=#2df7b2>Dictionary<{ TypeOfKeys . FullName } , { TypeOfValues . FullName } ></color>";
214
220
if ( GUILayout . Button ( btnLabel , new GUILayoutOption [ ] { GUILayout . Width ( negativeWhitespace ) } ) )
@@ -260,21 +266,27 @@ public override void DrawValue(Rect window, float width)
260
266
261
267
//GUIUnstrip.Space(whitespace);
262
268
263
- if ( key == null || val == null )
269
+ if ( key == null && val == null )
264
270
{
265
271
GUILayout . Label ( $ "[{ i } ] <i><color=grey>(null)</color></i>", new GUILayoutOption [ 0 ] ) ;
266
272
}
267
273
else
268
274
{
269
275
GUI . skin . label . alignment = TextAnchor . MiddleCenter ;
270
- GUILayout . Label ( $ "[{ i } ]", new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) ;
276
+ GUILayout . Label ( $ "[{ i } ]", new GUILayoutOption [ ] { GUILayout . Width ( 40 ) } ) ;
271
277
272
278
GUI . skin . label . alignment = TextAnchor . MiddleLeft ;
273
279
GUILayout . Label ( "Key:" , new GUILayoutOption [ ] { GUILayout . Width ( 40 ) } ) ;
274
- key . DrawValue ( window , ( window . width / 2 ) - 80f ) ;
280
+ if ( key != null )
281
+ key . DrawValue ( window , ( window . width / 2 ) - 80f ) ;
282
+ else
283
+ GUILayout . Label ( "<i>null</i>" , new GUILayoutOption [ 0 ] ) ;
275
284
276
285
GUILayout . Label ( "Value:" , new GUILayoutOption [ ] { GUILayout . Width ( 40 ) } ) ;
277
- val . DrawValue ( window , ( window . width / 2 ) - 80f ) ;
286
+ if ( Value != null )
287
+ val . DrawValue ( window , ( window . width / 2 ) - 80f ) ;
288
+ else
289
+ GUILayout . Label ( "<i>null</i>" , new GUILayoutOption [ 0 ] ) ;
278
290
}
279
291
280
292
}
0 commit comments