File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 44using TNRD . Utilities ;
55using UnityEditor ;
66using UnityEditor . IMGUI . Controls ;
7+ using UnityEngine ;
78using UnityEngine . Assertions ;
89
910namespace TNRD . Builders
@@ -37,6 +38,12 @@ public AdvancedDropdownItem Build()
3738 {
3839 CreateItemForPath ( root , assetPath ) ;
3940 }
41+ else if ( assetType == typeof ( GameObject ) )
42+ {
43+ GameObject gameObject = AssetDatabase . LoadAssetAtPath < GameObject > ( assetPath ) ;
44+ if ( gameObject . GetComponent ( interfaceType ) != null )
45+ CreateItemForPath ( root , assetPath ) ;
46+ }
4047 }
4148
4249 return root ;
Original file line number Diff line number Diff line change @@ -101,17 +101,13 @@ private void AvoidDuplicateReferencesInArray()
101101 if ( previousPropertyPath == Property . propertyPath )
102102 return ;
103103
104- SerializedProperty rawReferenceProperty = Property . FindPropertyRelative ( "rawReference" ) ;
105104 object currentReferenceValue = RawReferenceValue ;
106105
107106 if ( currentReferenceValue == null )
108107 return ;
109108
110109 if ( previousReferenceValue == currentReferenceValue )
111- {
112- RawReferenceValue = CreateInstance ( currentReferenceValue ) ;
113- rawReferenceProperty . serializedObject . ApplyModifiedProperties ( ) ;
114- }
110+ PropertyValue = CreateInstance ( currentReferenceValue ) ;
115111
116112 previousReferenceValue = currentReferenceValue ;
117113 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ protected object PropertyValue
8181 UnityReferenceProperty . objectReferenceValue = null ;
8282 break ;
8383 case ReferenceMode . Unity :
84- UnityReferenceProperty . objectReferenceValue = ( Object ) value ;
84+ UnityReferenceProperty . objectReferenceValue = GetUnityObject ( ( Object ) value ) ;
8585 RawReferenceValue = null ;
8686 break ;
8787 default :
@@ -138,6 +138,7 @@ private void OnClicked()
138138
139139 private void OnDeletePressed ( )
140140 {
141+ ModeValue = default ;
141142 PropertyValue = null ;
142143 }
143144
@@ -199,7 +200,7 @@ private void HandleDragUpdated()
199200 {
200201 Type scriptType = monoScript . GetClass ( ) ;
201202
202- if ( scriptType . IsSubclassOf ( typeof ( UnityEngine . Object ) ) )
203+ if ( scriptType . IsSubclassOf ( typeof ( Object ) ) )
203204 {
204205 SetDragAndDropMode ( false ) ;
205206 return ;
@@ -238,6 +239,13 @@ private void HandleDragPerform()
238239 }
239240 }
240241
242+ private Object GetUnityObject ( Object objectReference )
243+ {
244+ if ( objectReference is GameObject gameObject )
245+ return gameObject . GetComponent ( GenericType ) ;
246+ return objectReference ;
247+ }
248+
241249 protected abstract void PingObject ( ) ;
242250 }
243251}
You can’t perform that action at this time.
0 commit comments