Skip to content

Animator Extensions

Andrzej Kebab edited this page Feb 2, 2024 · 1 revision

UtilityLibrary.Unity.Runtime

Parameter Handling

ResetParameters

Resets all parameters of the animator to their default values.

animator.ResetParameters();

Parameters:

  • No parameters.

Returns:

  • No return value.

CheckParameterExist

Checks if a parameter with the specified name exists in the animator.

// Example of usage
bool exists = animator.CheckParameterExist("parameterName");

Parameters:

  • {string} parameterName: The name of the parameter to check.

Returns:

  • {bool}: True if the parameter exists, false otherwise.

CheckParameterExist (with type)

Checks if a parameter with the specified name and type exists in the animator.

// Example of usage
bool exists = animator.CheckParameterExist("parameterName", AnimatorControllerParameterType.Float);

Parameters:

  • {string} parameterName: The name of the parameter to check.
  • {AnimatorControllerParameterType} type: The type of the parameter to check.

Returns:

  • {bool}: True if the parameter exists and is of the specified type, false otherwise.

Clip Handling

CheckClipExist

Checks if a clip with the specified name exists in the animator.

// Example of usage
bool exists = animator.CheckClipExist("clipName");

Parameters:

  • {string} clipName: The name of the clip to check.

Returns:

  • {bool}: True if the clip exists, false otherwise.

Layer Handling

GetLayerWeight

Gets the weight of the specified layer in the animator.

// Example of usage
float weight = animator.GetLayerWeight("layerName");

Parameters:

  • {string} layerName: The name of the layer to get the weight of.

Returns:

  • {float}: The weight of the specified layer.

SetLayerWeight

Sets the weight of the specified layer in the animator.

// Example of usage
animator.SetLayerWeight("layerName", 0.5f);

Parameters:

  • {string} layerName: The name of the layer to set the weight of.
  • {float} weight: The weight to set.

Returns:

  • No return value.

CheckLayerExist

Checks if a layer with the specified name exists in the animator.

// Example of usage
bool exists = animator.CheckLayerExist("layerName");

Parameters:

  • {string} layerName: The name of the layer to check.

Returns:

  • {bool}: True if the layer exists, false otherwise.

Animator State Information

GetCurrentAnimatorStateInfo

Gets the current state information of the specified layer in the animator.

// Example of usage
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo("layerName");

Parameters:

  • {string} layerName: The name of the layer to get the state information of.

Returns:

  • {AnimatorStateInfo}: The current state information of the specified layer.

Clone this wiki locally