AnimatorParameterAttribute

The AnimatorParameterAttribute is a custom attribute that allows you to display all the parameters from an Animator component directly in the Unity Inspector. This makes it easy to select which animator parameter to trigger, without needing to modify the code directly.

Requirements

  • A GameObject with an Animator component and an assigned Animator Controller.

Usage Examples

[SerializeField]
[AnimatorParameter]
private string _yourAnotherVariable;

/* with custom parameter */

[SerializeField]
[AnimatorParameter(AnimatorControllerParameterType.Trigger)]
private string _yourVariable;
  • AnimatorControllerParameterType (Optional):

    • If you want to filter and display only specific types of parameters (e.g., only triggers), you can use AnimatorControllerParameterType.Trigger or any other type as needed.

Inspector Preview

  • When using this attribute, the Unity Inspector will display a dropdown list of all the animator parameters matching the specified type. This allows you to select the desired parameter without needing to hard-code it, offering a more flexible and editor-friendly approach to managing animation parameters.

Last updated