diff --git a/Editor/Builders/AssetsItemBuilder.cs b/Editor/Builders/AssetsItemBuilder.cs index 03dff70..dd1fe70 100644 --- a/Editor/Builders/AssetsItemBuilder.cs +++ b/Editor/Builders/AssetsItemBuilder.cs @@ -4,6 +4,7 @@ using TNRD.Utilities; using UnityEditor; using UnityEditor.IMGUI.Controls; +using UnityEngine; using UnityEngine.Assertions; namespace TNRD.Builders @@ -37,6 +38,12 @@ public AdvancedDropdownItem Build() { CreateItemForPath(root, assetPath); } + else if (assetType == typeof(GameObject)) + { + GameObject gameObject = AssetDatabase.LoadAssetAtPath(assetPath); + if (gameObject.GetComponent(interfaceType) != null) + CreateItemForPath(root, assetPath); + } } return root; diff --git a/Editor/Drawers/RawReferenceDrawer.cs b/Editor/Drawers/RawReferenceDrawer.cs index 9a74735..bbb32bb 100644 --- a/Editor/Drawers/RawReferenceDrawer.cs +++ b/Editor/Drawers/RawReferenceDrawer.cs @@ -101,17 +101,13 @@ private void AvoidDuplicateReferencesInArray() if (previousPropertyPath == Property.propertyPath) return; - SerializedProperty rawReferenceProperty = Property.FindPropertyRelative("rawReference"); object currentReferenceValue = RawReferenceValue; if (currentReferenceValue == null) return; if (previousReferenceValue == currentReferenceValue) - { - RawReferenceValue = CreateInstance(currentReferenceValue); - rawReferenceProperty.serializedObject.ApplyModifiedProperties(); - } + PropertyValue = CreateInstance(currentReferenceValue); previousReferenceValue = currentReferenceValue; } diff --git a/Editor/Drawers/ReferenceDrawer.cs b/Editor/Drawers/ReferenceDrawer.cs index 1137a98..56456fd 100644 --- a/Editor/Drawers/ReferenceDrawer.cs +++ b/Editor/Drawers/ReferenceDrawer.cs @@ -81,7 +81,7 @@ protected object PropertyValue UnityReferenceProperty.objectReferenceValue = null; break; case ReferenceMode.Unity: - UnityReferenceProperty.objectReferenceValue = (Object)value; + UnityReferenceProperty.objectReferenceValue = GetUnityObject((Object)value); RawReferenceValue = null; break; default: @@ -138,6 +138,7 @@ private void OnClicked() private void OnDeletePressed() { + ModeValue = default; PropertyValue = null; } @@ -199,7 +200,7 @@ private void HandleDragUpdated() { Type scriptType = monoScript.GetClass(); - if (scriptType.IsSubclassOf(typeof(UnityEngine.Object))) + if (scriptType.IsSubclassOf(typeof(Object))) { SetDragAndDropMode(false); return; @@ -238,6 +239,13 @@ private void HandleDragPerform() } } + private Object GetUnityObject(Object objectReference) + { + if(objectReference is GameObject gameObject) + return gameObject.GetComponent(GenericType); + return objectReference; + } + protected abstract void PingObject(); } }