public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(_target);
// If the target is set...
if (_target.objectReferenceValue != null)
{
// Cache the property list of the target.
CachePropertyList(_target.objectReferenceValue.GetType());
// If there are suitable candidates...
if (_propertyList.Length > 0)
{
// Show the drop-down list.
var index = Array.IndexOf(_propertyList, _propertyName.stringValue);
var newIndex = EditorGUILayout.Popup("Property", index, _propertyList);
// Update the property if the selection was changed.
if (index != newIndex)
_propertyName.stringValue = _propertyList[newIndex];
}
else
_propertyName.stringValue = ""; // reset on failure
}
else
_propertyName.stringValue = ""; // reset on failure
serializedObject.ApplyModifiedProperties();
}
}