I have a property drawer that is supposed to allow the selection of animator parameters from an enumPopup.
[CustomPropertyDrawer(typeof(Reaction))]
[CanEditMultipleObjects]
public class ReactionDrawer : PropertyDrawer
{
AnimatorController animCntrl;
AnimatorControllerParameter[] parameters;
string[] parameter_names = new string[0];
int selectedParameter = 0;
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if(animCntrl == null)
{
if(Selection.activeGameObject != null)
{
animCntrl = (AnimatorController)Selection.activeGameObject.GetComponent<Animator>().runtimeAnimatorController;
}
else
{
return;
}
_init(); //populates the parameter and parameter names array
}
SerializedProperty parameter = property.FindPropertyRelative("parameter");
SerializedProperty type = property.FindPropertyRelative("type");
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
// Draw label
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
var paramRect = new Rect(position.x, position.y, position.width/2, position.height);
var typeRect = new Rect(position.x + position.width/2 + 5, position.y, position.width/4, position.height);
var valRect = new Rect(position.x + (position.width/4)*3 + 5 , position.y, position.width/4, position.height);
if (parameters.Length > 0)
{
selectedParameter = EditorGUI.Popup(paramRect, selectedParameter, parameter_names);
parameter.stringValue = parameters[selectedParameter].name;
SetParameterType(type);
EditorGUI.LabelField(typeRect, type.enumDisplayNames[type.enumValueIndex]);
DrawValueField(valRect, property);
}
else
{
EditorGUI.LabelField(new Rect(position.x, position.y, position.width, position.height), "No parameters found in Animator Controller");
}
EditorGUI.EndProperty();
}
The Reaction Property itself:
[System.Serializable]
public class Reaction
{
public enum reactionType {boolean = 0, trigger = 1, integer = 2, floating = 3 , none = 4};
public reactionType type = reactionType.none;
public string parameter;
//rather than fool with types, keep them all.
public bool value_bool;
public int value_int;
public float value_float;
}
Pictured, you see the Reactor component, which keeps an array of Reactions.

What happens is that when I change the popup value in one box, it changes for all the elements in the array. What am I missing?