public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(_target);
// Try to retrieve the target shader.
var shader = RetrieveTargetShader(_target.objectReferenceValue);
if (shader != null)
{
// Cache the property list of the target shader.
CachePropertyList(shader);
// 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();
}
}