@@ -46,9 +46,10 @@ public static void ObjectField(Rect rect, SerializedProperty property, GUIConten
46
46
public static Object ObjectField ( Rect rect , GUIContent label , Object currentTarget , Type objType ,
47
47
bool allowSceneObjects )
48
48
{
49
- return objType . IsGenericType
50
- ? EditorGUIHelper . GenericObjectField ( rect , label , currentTarget , objType , allowSceneObjects )
51
- : EditorGUI . ObjectField ( rect , label ?? GUIContent . none , currentTarget , objType , allowSceneObjects ) ;
49
+ if ( objType . IsGenericType || IsTargetGeneric ( currentTarget ) )
50
+ return EditorGUIHelper . GenericObjectField ( rect , label , currentTarget , objType , allowSceneObjects ) ;
51
+
52
+ return EditorGUI . ObjectField ( rect , label ?? GUIContent . none , currentTarget , objType , allowSceneObjects ) ;
52
53
}
53
54
54
55
/// <summary>
@@ -64,9 +65,25 @@ public static Object ObjectField(Rect rect, GUIContent label, Object currentTarg
64
65
public static Object ObjectField ( string label , Object currentTarget , Type objType ,
65
66
bool allowSceneObjects )
66
67
{
67
- return objType . IsGenericType
68
- ? EditorGUILayoutHelper . GenericObjectField ( label , currentTarget , objType , allowSceneObjects )
69
- : EditorGUILayout . ObjectField ( label , currentTarget , objType , allowSceneObjects ) ;
68
+ if ( objType . IsGenericType || IsTargetGeneric ( currentTarget ) )
69
+ {
70
+ return EditorGUILayoutHelper . GenericObjectField ( label , currentTarget , objType , allowSceneObjects ) ;
71
+ }
72
+
73
+ return EditorGUILayout . ObjectField ( label , currentTarget , objType , allowSceneObjects ) ;
74
+ }
75
+
76
+ private static bool IsTargetGeneric ( Object target )
77
+ {
78
+ if ( target == null )
79
+ return false ;
80
+
81
+ var targetBaseType = target . GetType ( ) . BaseType ;
82
+
83
+ if ( targetBaseType == null )
84
+ return false ;
85
+
86
+ return targetBaseType . IsGenericType ;
70
87
}
71
88
}
72
89
}
0 commit comments