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"?
}
}
}