文档

Unity Engine

Unity Engine

GetParameter(int)

Obtains a reference to the AnimatorControllerParameter at the given index.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.AnimationModule
public AnimatorControllerParameter GetParameter(int index)

Parameters

index

The index of the parameter to obtain.

Returns

Type

Description

AnimatorControllerParameterThe parameter at the given index.

Remarks

Throws an
IndexOutOfRangeException
when the index is not in the range from greater than or equal to 0 to less than Animator.parameterCount.
using UnityEngine;// This example demonstrates how to use the Animator.GetParameter method to get information about the parameters of an Animator controller.[RequireComponent(typeof(Animator))]public class GetParameterExample : MonoBehaviour{ Animator m_Animator; void Start() { m_Animator = GetComponent<Animator>(); for (var i = 0; i < m_Animator.parameterCount; i++) { var parameter = m_Animator.GetParameter(i); Debug.Log($"Parameter {i}: {parameter.name} ({parameter.type})"); } }}
Additional Resources: AnimationParameters manual. AnimatorController.parameters for accessing the list of parameters.