@@ -29,9 +29,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
29
29
EditorGUI . BeginProperty ( position , label , property ) ;
30
30
EditorGUI . BeginChangeCheck ( ) ;
31
31
32
- Type fieldType = fieldInfo . FieldType ;
32
+ Type fieldType = null ;
33
+ bool isUnityObject = typeof ( UnityEngine . Object ) . IsAssignableFrom ( fieldInfo . FieldType ) ;
34
+ if ( isUnityObject || fieldInfo . FieldType . IsValueType || property . propertyType != SerializedPropertyType . ManagedReference ) {
35
+ fieldType = fieldInfo . FieldType ;
36
+ }
37
+ else {
38
+ string [ ] info = property . managedReferenceFieldTypename . Split ( ) ;
39
+ string asseblyName = info [ 0 ] , typeName = info [ 1 ] ;
40
+ Assembly assembly = AppDomain . CurrentDomain . GetAssemblies ( ) . FirstOrDefault ( item => item . GetName ( ) . Name == asseblyName ) ;
41
+ fieldType = assembly . GetType ( typeName ) ;
42
+ }
43
+
33
44
if ( fieldType . IsAbstract || fieldType . IsInterface ) {
34
- ShowPolymorphismField ( position , property , label ) ;
45
+ ShowPolymorphismField ( fieldType , position , property , label ) ;
35
46
}
36
47
else {
37
48
EditorGUI . PropertyField ( position , property , label , true ) ;
@@ -62,9 +73,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
62
73
#region Show Polymorphism Field
63
74
private readonly static Dictionary < Type , List < Type > > _subTypeDict = new ( ) ;
64
75
65
- private void ShowPolymorphismField ( Rect position , SerializedProperty property , GUIContent label ) {
76
+ private void ShowPolymorphismField ( Type abstractType , Rect position , SerializedProperty property , GUIContent label ) {
66
77
// 绘制选择框
67
- Type abstractType = fieldInfo . FieldType ;
68
78
List < Type > subTypes = GetSubTypes ( abstractType ) ;
69
79
70
80
Rect labelRect = EditorGUI . IndentedRect ( new ( position ) {
0 commit comments