@@ -17,8 +17,7 @@ public sealed class CollectionItemIndirectReferencePropertyDrawer : PropertyDraw
1717
1818 private Type collectionItemType ;
1919 private CollectionItemPropertyDrawer collectionItemPropertyDrawer ;
20-
21- private SerializedProperty drawingProperty ;
20+
2221 private SerializedProperty itemGUIDValueASerializedProperty ;
2322 private SerializedProperty itemGUIDValueBSerializedProperty ;
2423 private SerializedProperty itemLastKnowNameSerializedProperty ;
@@ -43,7 +42,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
4342 if ( collectionItemPropertyDrawer == null )
4443 CreateCollectionItemPropertyDrawer ( property ) ;
4544
46- drawingProperty = property ;
4745 itemGUIDValueASerializedProperty = property . FindPropertyRelative ( COLLECTION_ITEM_GUID_VALUE_A_PROPERTY_PATH ) ;
4846 itemGUIDValueBSerializedProperty = property . FindPropertyRelative ( COLLECTION_ITEM_GUID_VALUE_B_PROPERTY_PATH ) ;
4947 itemLastKnowNameSerializedProperty = property . FindPropertyRelative ( COLLECTION_ITEM_LAST_KNOW_NAME_PROPERTY_PATH ) ;
@@ -66,41 +64,47 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
6664 {
6765 collectionItemPropertyDrawer . DrawCollectionItemDrawer ( ref position , property , collectionItem , label , item =>
6866 {
69- SetSerializedPropertyGUIDs ( item ) ;
70- drawingProperty . serializedObject . ApplyModifiedProperties ( ) ;
67+ var element = property . serializedObject . FindProperty ( property . propertyPath ) ;
68+ SetSerializedPropertyGUIDs ( element , item ) ;
69+ property . serializedObject . ApplyModifiedProperties ( ) ;
7170 } ) ;
7271 return ;
7372 }
7473
7574 EditorGUI . PropertyField ( position , property , label , true ) ;
7675 }
7776
78- private void SetSerializedPropertyGUIDs ( ScriptableObject item )
77+ private void SetSerializedPropertyGUIDs ( SerializedProperty element , ScriptableObject item )
7978 {
79+ SerializedProperty itemA = element . FindPropertyRelative ( COLLECTION_ITEM_GUID_VALUE_A_PROPERTY_PATH ) ;
80+ SerializedProperty itemB = element . FindPropertyRelative ( COLLECTION_ITEM_GUID_VALUE_B_PROPERTY_PATH ) ;
81+ SerializedProperty itemName = element . FindPropertyRelative ( COLLECTION_ITEM_LAST_KNOW_NAME_PROPERTY_PATH ) ;
82+ SerializedProperty colA = element . FindPropertyRelative ( COLLECTION_GUID_VALUE_A_PROPERTY_PATH ) ;
83+ SerializedProperty colB = element . FindPropertyRelative ( COLLECTION_GUID_VALUE_B_PROPERTY_PATH ) ;
84+ SerializedProperty colName = element . FindPropertyRelative ( COLLECTION_LAST_KNOW_NAME_PROPERTY_PATH ) ;
85+
8086 if ( item == null )
8187 {
82- itemGUIDValueASerializedProperty . longValue = 0 ;
83- itemGUIDValueBSerializedProperty . longValue = 0 ;
84- collectionGUIDValueASerializedProperty . longValue = 0 ;
85- collectionGUIDValueBSerializedProperty . longValue = 0 ;
86- itemLastKnowNameSerializedProperty . stringValue = string . Empty ;
87- collectionLastKnowNameSerializedProperty . stringValue = string . Empty ;
88-
88+ itemA . longValue = 0 ;
89+ itemB . longValue = 0 ;
90+ colA . longValue = 0 ;
91+ colB . longValue = 0 ;
92+ itemName . stringValue = string . Empty ;
93+ colName . stringValue = string . Empty ;
94+ return ;
8995 }
90- else
96+
97+ if ( item is ISOCItem socItem )
9198 {
92- if ( item is ISOCItem socItem )
93- {
94- ( long , long ) itemGUIDValues = socItem . GUID . GetRawValues ( ) ;
95- itemGUIDValueASerializedProperty . longValue = itemGUIDValues . Item1 ;
96- itemGUIDValueBSerializedProperty . longValue = itemGUIDValues . Item2 ;
97- itemLastKnowNameSerializedProperty . stringValue = socItem . name ;
98-
99- ( long , long ) collectionGUIDValues = socItem . Collection . GUID . GetRawValues ( ) ;
100- collectionGUIDValueASerializedProperty . longValue = collectionGUIDValues . Item1 ;
101- collectionGUIDValueBSerializedProperty . longValue = collectionGUIDValues . Item2 ;
102- collectionLastKnowNameSerializedProperty . stringValue = socItem . Collection . name ;
103- }
99+ ( long ia , long ib ) = socItem . GUID . GetRawValues ( ) ;
100+ itemA . longValue = ia ;
101+ itemB . longValue = ib ;
102+ itemName . stringValue = socItem . name ;
103+
104+ ( long ca , long cb ) = socItem . Collection . GUID . GetRawValues ( ) ;
105+ colA . longValue = ca ;
106+ colB . longValue = cb ;
107+ colName . stringValue = socItem . Collection . name ;
104108 }
105109
106110 }
@@ -152,4 +156,4 @@ private SOCItemEditorOptionsAttribute GetOptionsAttribute()
152156 return null ;
153157 }
154158 }
155- }
159+ }
0 commit comments