Find an instance of a scriptable object in project in an editor script

I have an abstract base class for scriptable objects named “FindableSO”.
I want to draw a button next to every field of this type in the inspector. For this part I have created a CustomPropertyDrawer which works.
When the button is clicked, I want to search Unity project and find an instance of the type of the property.
The problem is that I don’t know how can I find an instance of a serialized property in the project.
Any idea how can I do it?

    [CustomPropertyDrawer(typeof(FindableSO))]
    public class FindableSODrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect fieldRect = position.SubXMax(60);
            EditorGUI.PropertyField(fieldRect, property, label);

            if (GUI.Button(new Rect(fieldRect.xMax, fieldRect.y, 60, fieldRect.height), "Find SO"))
            {
                 // What to do here with "property"?
            }
        }
    }

Try AssetDatabase.FindAssets(). You can use a search string like “t:FindableSO”

1 Like

Thanks. There’s another problem though. I cannot find a way to check if the “FindableSO” instance that is returned by FindAssets is the right instance for this field or not. For example, I might have these:

// SOType1.cs
public class SOType1 : FindableSO {}

// SOType2.cs
public class SOType2 : FindableSO {}

// MB.cs
public class MB : MonoBehaviour
{
    public SOType2 Obj;
}

For this example “FindAssets” will return two paths. How can I assign the right object (SoType2.asset) to the “Obj” field?