Get list of parameters of an AnimatorController

In Animator class, it is possible to set parameters using SetFloat, SetBool, SetInteger, etc…

Is it possible to know if a parameter exists before setting it?

For Unity 4.3, things have changed a bit, there is a new class called AnimatorControllerParameter which is used to get these parameters.

public Animator animator;

void Start()
    AnimatorController animatorController = AnimatorController.GetEffectiveAnimatorController(animator);
    int countParameters = animatorController.parameterCount;
    AnimatorControllerParameter[] animationCParameter = new AnimatorControllerParameter[countParameters];

    for (int i = 0; i < countParameters; i++)
        animationCParameter *= animatorController.GetParameter(i);*

Debug.Log("Parameter Name: " + animationCParameter*.name);*
if (animationCParameter*.type == AnimatorControllerParameterType.Bool)*
Debug.Log("Default Bool: " + animationCParameter*.defaultBool);*
else if (animationCParameter*.type == AnimatorControllerParameterType.Float)*
Debug.Log("Default Float: " + animationCParameter*.defaultFloat);*
else if (animationCParameter*.type == AnimatorControllerParameterType.Int)*
Debug.Log("Default Int: " + animationCParameter*.defaultInt);*

It’s not possible (Unity 4.1) at runtime to query the list of parameters that an animator has. But it is possible at edit time using using the UnityEditorInternal namespace.

You can use these methods:

animatorController.GetEventCount(); //returns the count of parameters
animatorController.GetEventType(int index); //returns the index of the type(type -> see AnimatorControllerEventType)
//Gets the default values for parameters
animatorController.GetEventDefaultBool(int index);
animatorController.GetEventDefaultFloat(int index);
animatorController.GetEventDefaultInt(int index);
animatorController.GetEventDefaultVector(int index);
//Gets the name of the parameter
animatorController.GetEventName(int index);

Also there is a “Set” version of previous Methods.

You can create an Editor script that saves this data into an ScriptableObject saved as an asset or you could save the data in a script automatically using a CustomEditor inspector:

[CustomEditor(typeof( ClassHoldingAnimatorInfo ))]
public class ClassHoldingAnimatorInfoInspector : Editor
   public override void OnInspectorGUI()
       if (GUI.changed)
           ClassHoldingAnimatorInfo classInstance = target as ClassHoldingAnimatorInfo;

           Animator animator = classInstance.gameObject.GetComponent<Animator>();

           AnimatorController animatorController = AnimatorController.GetAnimatorController (animator);

           // get the data from the Animator using the functions from above
           // and assign it to serialized variables in the classInstance

You can then query this data at runtime.

I suspect this part of the API is in flux at the moment. Here’s code that works for me in 5.1.1f1 based on @chechoggomez post (and/or doesn’t require the UnityEditorInternal).

    AnimatorControllerParameter param;
    for (int i = 0; i < anim.parameters.Length; i++) {
        param = anim.parameters*;*

Debug.Log("Parameter Name: " +;

if (param.type == AnimatorControllerParameterType.Bool){
Debug.Log("Default Bool: " + param.defaultBool);
else if (param.type == AnimatorControllerParameterType.Float){
Debug.Log("Default Float: " + param.defaultFloat);
else if (param.type == AnimatorControllerParameterType.Int){
Debug.Log("Default Int: " + param.defaultInt);