@@ -28,46 +28,38 @@ public enum ValueState
2828 public abstract class CacheObjectBase
2929 {
3030 public ICacheObjectController Owner { get ; set ; }
31-
3231 public CacheObjectCell CellView { get ; internal set ; }
3332
3433 public object Value { get ; protected set ; }
3534 public Type FallbackType { get ; protected set ; }
36- public bool LastValueWasNull { get ; private set ; }
37-
38- public ValueState State = ValueState . NotEvaluated ;
39- public Type LastValueType ;
35+ public ValueState State { get ; set ; }
36+ public Exception LastException { get ; protected set ; }
37+ bool valueIsNull ;
38+ Type currentValueType ;
4039
40+ // InteractiveValues
4141 public InteractiveValue IValue { get ; private set ; }
4242 public Type CurrentIValueType { get ; private set ; }
4343 public bool SubContentShowWanted { get ; private set ; }
4444
45+ // UI
4546 public string NameLabelText { get ; protected set ; }
4647 public string NameLabelTextRaw { get ; protected set ; }
4748 public string ValueLabelText { get ; protected set ; }
4849
50+ // Abstract
4951 public abstract bool ShouldAutoEvaluate { get ; }
5052 public abstract bool HasArguments { get ; }
5153 public abstract bool CanWrite { get ; }
52- public Exception LastException { get ; protected set ; }
54+
55+ protected const string NOT_YET_EVAL = "<color=grey>Not yet evaluated</color>" ;
5356
5457 public virtual void SetFallbackType ( Type fallbackType )
5558 {
5659 this . FallbackType = fallbackType ;
5760 this . ValueLabelText = GetValueLabel ( ) ;
5861 }
5962
60- protected const string NOT_YET_EVAL = "<color=grey>Not yet evaluated</color>" ;
61-
62- public virtual void ReleasePooledObjects ( )
63- {
64- if ( this . IValue != null )
65- ReleaseIValue ( ) ;
66-
67- if ( this . CellView != null )
68- UnlinkFromView ( ) ;
69- }
70-
7163 public virtual void SetView ( CacheObjectCell cellView )
7264 {
7365 this . CellView = cellView ;
@@ -86,6 +78,15 @@ public virtual void UnlinkFromView()
8678 this . IValue . UIRoot . transform . SetParent ( InactiveIValueHolder . transform , false ) ;
8779 }
8880
81+ public virtual void ReleasePooledObjects ( )
82+ {
83+ if ( this . IValue != null )
84+ ReleaseIValue ( ) ;
85+
86+ if ( this . CellView != null )
87+ UnlinkFromView ( ) ;
88+ }
89+
8990 // Updating and applying values
9091
9192 // The only method which sets the CacheObjectBase.Value
@@ -130,18 +131,18 @@ protected virtual void ProcessOnEvaluate()
130131
131132 if ( LastException != null )
132133 {
133- LastValueWasNull = true ;
134- LastValueType = FallbackType ;
134+ valueIsNull = true ;
135+ currentValueType = FallbackType ;
135136 State = ValueState . Exception ;
136137 }
137138 else if ( Value . IsNullOrDestroyed ( ) )
138139 {
139- LastValueWasNull = true ;
140+ valueIsNull = true ;
140141 State = GetStateForType ( FallbackType ) ;
141142 }
142143 else
143144 {
144- LastValueWasNull = false ;
145+ valueIsNull = false ;
145146 State = GetStateForType ( Value . GetActualType ( ) ) ;
146147 }
147148
@@ -163,10 +164,10 @@ protected virtual void ProcessOnEvaluate()
163164
164165 public ValueState GetStateForType ( Type type )
165166 {
166- if ( LastValueType == type && ( State != ValueState . Exception || LastException != null ) )
167+ if ( currentValueType == type && ( State != ValueState . Exception || LastException != null ) )
167168 return State ;
168169
169- LastValueType = type ;
170+ currentValueType = type ;
170171 if ( type == typeof ( bool ) )
171172 return ValueState . Boolean ;
172173 else if ( type . IsPrimitive || type == typeof ( decimal ) )
@@ -189,7 +190,7 @@ public ValueState GetStateForType(Type type)
189190
190191 protected string GetValueLabel ( )
191192 {
192- string label = "" ;
193+ string label = string . Empty ;
193194
194195 switch ( State )
195196 {
@@ -206,19 +207,19 @@ protected string GetValueLabel()
206207
207208 // and valuestruct also doesnt want it if we can parse it
208209 case ValueState . ValueStruct :
209- if ( ParseUtility . CanParse ( LastValueType ) )
210+ if ( ParseUtility . CanParse ( currentValueType ) )
210211 return null ;
211212 break ;
212213
213214 // string wants it trimmed to max 200 chars
214215 case ValueState . String :
215- if ( ! LastValueWasNull )
216+ if ( ! valueIsNull )
216217 return $ "\" { ToStringUtility . PruneString ( Value as string , 200 , 5 ) } \" ";
217218 break ;
218219
219220 // try to prefix the count of the collection for lists and dicts
220221 case ValueState . Collection :
221- if ( ! LastValueWasNull )
222+ if ( ! valueIsNull )
222223 {
223224 if ( Value is IList iList )
224225 label = $ "[{ iList . Count } ] ";
@@ -230,7 +231,7 @@ protected string GetValueLabel()
230231 break ;
231232
232233 case ValueState . Dictionary :
233- if ( ! LastValueWasNull )
234+ if ( ! valueIsNull )
234235 {
235236 if ( Value is IDictionary iDict )
236237 label = $ "[{ iDict . Count } ] ";
@@ -291,7 +292,7 @@ public virtual void SetDataToCell(CacheObjectCell cell)
291292 SetValueState ( cell , new ( false , typeLabelActive : true , inputActive : true , applyActive : CanWrite ) ) ;
292293 break ;
293294 case ValueState . String :
294- if ( LastValueWasNull )
295+ if ( valueIsNull )
295296 SetValueState ( cell , new ( true , subContentButtonActive : true ) ) ;
296297 else
297298 SetValueState ( cell , new ( true , false , SignatureHighlighter . StringOrange , subContentButtonActive : true ) ) ;
@@ -301,17 +302,17 @@ public virtual void SetDataToCell(CacheObjectCell cell)
301302 break ;
302303 case ValueState . Color :
303304 case ValueState . ValueStruct :
304- if ( ParseUtility . CanParse ( LastValueType ) )
305+ if ( ParseUtility . CanParse ( currentValueType ) )
305306 SetValueState ( cell , new ( false , false , null , true , false , true , CanWrite , true , true ) ) ;
306307 else
307308 SetValueState ( cell , new ( true , inspectActive : true , subContentButtonActive : true ) ) ;
308309 break ;
309310 case ValueState . Collection :
310311 case ValueState . Dictionary :
311- SetValueState ( cell , new ( true , inspectActive : ! LastValueWasNull , subContentButtonActive : ! LastValueWasNull ) ) ;
312+ SetValueState ( cell , new ( true , inspectActive : ! valueIsNull , subContentButtonActive : ! valueIsNull ) ) ;
312313 break ;
313314 case ValueState . Unsupported :
314- SetValueState ( cell , new ( true , inspectActive : ! LastValueWasNull ) ) ;
315+ SetValueState ( cell , new ( true , inspectActive : ! valueIsNull ) ) ;
315316 break ;
316317 }
317318
@@ -333,7 +334,7 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
333334 // Type label (for primitives)
334335 cell . TypeLabel . gameObject . SetActive ( args . typeLabelActive ) ;
335336 if ( args . typeLabelActive )
336- cell . TypeLabel . text = SignatureHighlighter . Parse ( LastValueType , false ) ;
337+ cell . TypeLabel . text = SignatureHighlighter . Parse ( currentValueType , false ) ;
337338
338339 // toggle for bools
339340 cell . Toggle . gameObject . SetActive ( args . toggleActive ) ;
@@ -348,7 +349,7 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
348349 cell . InputField . UIRoot . SetActive ( args . inputActive ) ;
349350 if ( args . inputActive )
350351 {
351- cell . InputField . Text = ParseUtility . ToStringForInput ( Value , LastValueType ) ;
352+ cell . InputField . Text = ParseUtility . ToStringForInput ( Value , currentValueType ) ;
352353 cell . InputField . Component . readOnly = ! CanWrite ;
353354 }
354355
@@ -357,12 +358,12 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
357358
358359 // Inspect button only if last value not null.
359360 if ( cell . InspectButton != null )
360- cell . InspectButton . Component . gameObject . SetActive ( args . inspectActive && ! LastValueWasNull ) ;
361+ cell . InspectButton . Component . gameObject . SetActive ( args . inspectActive && ! valueIsNull ) ;
361362
362363 // set subcontent button if needed, and for null strings and exceptions
363364 cell . SubContentButton . Component . gameObject . SetActive (
364365 args . subContentButtonActive
365- && ( ! LastValueWasNull || State == ValueState . String || State == ValueState . Exception ) ) ;
366+ && ( ! valueIsNull || State == ValueState . String || State == ValueState . Exception ) ) ;
366367 }
367368
368369 // CacheObjectCell Apply
@@ -373,7 +374,7 @@ public virtual void OnCellApplyClicked()
373374 SetUserValue ( this . CellView . Toggle . isOn ) ;
374375 else
375376 {
376- if ( ParseUtility . TryParse ( CellView . InputField . Text , LastValueType , out object value , out Exception ex ) )
377+ if ( ParseUtility . TryParse ( CellView . InputField . Text , currentValueType , out object value , out Exception ex ) )
377378 {
378379 SetUserValue ( value ) ;
379380 }
0 commit comments