@@ -24,6 +24,7 @@ enum PropertyType {
2424 Color ,
2525 Rect ,
2626 Bounds ,
27+ Gradient ,
2728 Curve ,
2829 String ,
2930 Object ,
@@ -68,6 +69,29 @@ public static class Helper {
6869 internal static readonly Dictionary < Type , PropertyType > propertyTypeMapper = new Dictionary < Type , PropertyType > ( ) ;
6970 internal static readonly Dictionary < Type , HashSet < string > > blackListedTypes = new Dictionary < Type , HashSet < string > > ( ) ;
7071 static double clickTime ;
72+
73+ // Delegate hacks to access the internal methods
74+ internal static readonly Func < GUIContent , Rect , Gradient , Gradient > doGradientField = Delegate . CreateDelegate (
75+ typeof ( Func < GUIContent , Rect , Gradient , Gradient > ) ,
76+ typeof ( EditorGUI ) . GetMethod (
77+ "GradientField" ,
78+ BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Static ,
79+ null , CallingConventions . Any ,
80+ new [ ] { typeof ( GUIContent ) , typeof ( Rect ) , typeof ( Gradient ) } ,
81+ null
82+ )
83+ ) as Func < GUIContent , Rect , Gradient , Gradient > ;
84+
85+ internal static readonly Func < GUIContent , Gradient , GUILayoutOption [ ] , Gradient > doLayoutGradiantField = Delegate . CreateDelegate (
86+ typeof ( Func < GUIContent , Gradient , GUILayoutOption [ ] , Gradient > ) ,
87+ typeof ( EditorGUILayout ) . GetMethod (
88+ "GradientField" ,
89+ BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Static ,
90+ null , CallingConventions . Any ,
91+ new [ ] { typeof ( GUIContent ) , typeof ( Gradient ) , typeof ( GUILayoutOption [ ] ) } ,
92+ null
93+ )
94+ ) as Func < GUIContent , Gradient , GUILayoutOption [ ] , Gradient > ;
7195
7296 internal static void InitPropertyTypeMapper ( ) {
7397 if ( propertyTypeMapper . Count > 0 )
@@ -91,6 +115,7 @@ internal static void InitPropertyTypeMapper() {
91115 AddPropertyTypeMap ( "UnityEngine.Color, UnityEngine.dll" , PropertyType . Color ) ;
92116 AddPropertyTypeMap ( "UnityEngine.Rect, UnityEngine.dll" , PropertyType . Rect ) ;
93117 AddPropertyTypeMap ( "UnityEngine.Bounds, UnityEngine.dll" , PropertyType . Bounds ) ;
118+ AddPropertyTypeMap ( "UnityEngine.Gradient, UnityEngine.dll" , PropertyType . Gradient ) ;
94119 AddPropertyTypeMap ( "UnityEngine.AnimationCurve, UnityEngine.dll" , PropertyType . Curve ) ;
95120 AddPropertyTypeMap ( "UnityEngine.Object, UnityEngine.dll" , PropertyType . Object ) ;
96121 AddPropertyTypeMap ( "System.Collections.Generic.IList`1" , PropertyType . Array ) ;
@@ -403,6 +428,14 @@ internal static UnityObject ObjectField(Rect position, GUIContent label, UnityOb
403428 return value ;
404429 }
405430
431+ internal static Gradient GradientField ( Rect position , GUIContent label , Gradient value ) {
432+ return doGradientField . Invoke ( label , position , value ) ;
433+ }
434+
435+ internal static Gradient GradientField ( GUIContent label , Gradient value , params GUILayoutOption [ ] options ) {
436+ return doLayoutGradiantField . Invoke ( label , value , options ) ;
437+ }
438+
406439 static void ClickObject ( UnityObject obj ) {
407440 var newClickTime = EditorApplication . timeSinceStartup ;
408441 if ( newClickTime - clickTime < 0.3 && obj != null )
0 commit comments