@@ -20,7 +20,8 @@ public abstract class CacheObjectBase
20
20
public Type DeclaringType { get ; set ; }
21
21
public object DeclaringInstance { get ; set ; }
22
22
23
- public bool HasParameters => m_arguments != null && m_arguments . Length > 0 ;
23
+ public virtual bool HasParameters => m_arguments != null && m_arguments . Length > 0 ;
24
+
24
25
public bool m_evaluated = false ;
25
26
public bool m_isEvaluating ;
26
27
public ParameterInfo [ ] m_arguments = new ParameterInfo [ 0 ] ;
@@ -394,26 +395,54 @@ public void Draw(Rect window, float labelWidth = 215f)
394
395
395
396
if ( m_isEvaluating )
396
397
{
397
- for ( int i = 0 ; i < m_arguments . Length ; i ++ )
398
+ if ( cm != null && cm . GenericArgs . Length > 0 )
398
399
{
399
- var name = m_arguments [ i ] . Name ;
400
- var input = m_argumentInput [ i ] ;
401
- var type = m_arguments [ i ] . ParameterType . Name ;
400
+ GUILayout . Label ( $ "<b><color=orange>Generic Arguments:</color></b>", null ) ;
402
401
403
- var label = $ "<color={ UIStyles . Syntax . Class_Instance } >{ type } </color> ";
404
- label += $ "<color={ UIStyles . Syntax . Local } >{ name } </color>";
405
- if ( m_arguments [ i ] . HasDefaultValue )
402
+ for ( int i = 0 ; i < cm . GenericArgs . Length ; i ++ )
406
403
{
407
- label = $ "<i>[{ label } = { m_arguments [ i ] . DefaultValue ?? "null" } ]</i>";
408
- }
404
+ var type = cm . GenericConstraints [ i ] ? . FullName ?? "None" ;
405
+ var input = cm . GenericArgInput [ i ] ;
406
+ var label = $ "<color={ UIStyles . Syntax . Class_Instance } >{ type } </color>";
409
407
410
- GUILayout . BeginHorizontal ( null ) ;
408
+ GUILayout . BeginHorizontal ( null ) ;
411
409
412
- GUILayout . Label ( i . ToString ( ) , new GUILayoutOption [ ] { GUILayout . Width ( 20 ) } ) ;
413
- m_argumentInput [ i ] = GUILayout . TextField ( input , new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) ;
414
- GUILayout . Label ( label , null ) ;
410
+ GUI . skin . label . alignment = TextAnchor . MiddleCenter ;
411
+ GUILayout . Label ( $ "<color={ UIStyles . Syntax . StructGreen } >{ cm . GenericArgs [ i ] . Name } </color>", new GUILayoutOption [ ] { GUILayout . Width ( 15 ) } ) ;
412
+ cm . GenericArgInput [ i ] = GUILayout . TextField ( input , new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) ;
413
+ GUI . skin . label . alignment = TextAnchor . MiddleLeft ;
414
+ GUILayout . Label ( label , null ) ;
415
415
416
- GUILayout . EndHorizontal ( ) ;
416
+ GUILayout . EndHorizontal ( ) ;
417
+ }
418
+ }
419
+
420
+ if ( m_arguments . Length > 0 )
421
+ {
422
+ GUILayout . Label ( $ "<b><color=orange>Arguments:</color></b>", null ) ;
423
+ for ( int i = 0 ; i < m_arguments . Length ; i ++ )
424
+ {
425
+ var name = m_arguments [ i ] . Name ;
426
+ var input = m_argumentInput [ i ] ;
427
+ var type = m_arguments [ i ] . ParameterType . Name ;
428
+
429
+ var label = $ "<color={ UIStyles . Syntax . Class_Instance } >{ type } </color> ";
430
+ label += $ "<color={ UIStyles . Syntax . Local } >{ name } </color>";
431
+ if ( m_arguments [ i ] . HasDefaultValue )
432
+ {
433
+ label = $ "<i>[{ label } = { m_arguments [ i ] . DefaultValue ?? "null" } ]</i>";
434
+ }
435
+
436
+ GUILayout . BeginHorizontal ( null ) ;
437
+
438
+ GUI . skin . label . alignment = TextAnchor . MiddleCenter ;
439
+ GUILayout . Label ( i . ToString ( ) , new GUILayoutOption [ ] { GUILayout . Width ( 15 ) } ) ;
440
+ m_argumentInput [ i ] = GUILayout . TextField ( input , new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) ;
441
+ GUI . skin . label . alignment = TextAnchor . MiddleLeft ;
442
+ GUILayout . Label ( label , null ) ;
443
+
444
+ GUILayout . EndHorizontal ( ) ;
445
+ }
417
446
}
418
447
419
448
GUILayout . BeginHorizontal ( null ) ;
@@ -436,7 +465,12 @@ public void Draw(Rect window, float labelWidth = 215f)
436
465
}
437
466
else
438
467
{
439
- if ( GUILayout . Button ( $ "Evaluate ({ m_arguments . Length } params)", new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) )
468
+ var lbl = $ "Evaluate (";
469
+ int args = m_arguments . Length ;
470
+ if ( cm != null ) args += cm . GenericArgs . Length ;
471
+ lbl += args + " params)" ;
472
+
473
+ if ( GUILayout . Button ( lbl , new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) )
440
474
{
441
475
m_isEvaluating = true ;
442
476
}
@@ -527,6 +561,24 @@ private string GetRichTextName()
527
561
m_richTextName += $ "<color={ memberColor } >{ MemInfo . Name } </color>";
528
562
if ( isStatic ) m_richTextName += "</i>" ;
529
563
564
+ // generic method args
565
+ if ( this is CacheMethod cm && cm . GenericArgs . Length > 0 )
566
+ {
567
+ m_richTextName += "<" ;
568
+
569
+ var args = "" ;
570
+ for ( int i = 0 ; i < cm . GenericArgs . Length ; i ++ )
571
+ {
572
+ if ( args != "" ) args += ", " ;
573
+ args += $ "<color={ UIStyles . Syntax . StructGreen } >{ cm . GenericArgs [ i ] . Name } </color>";
574
+ }
575
+ m_richTextName += args ;
576
+
577
+ m_richTextName += ">" ;
578
+ }
579
+
580
+ // Method / Property arguments
581
+
530
582
//if (m_arguments.Length > 0 || this is CacheMethod)
531
583
//{
532
584
// m_richTextName += "(";
0 commit comments