Legacy Documentation: Version 5.4
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AnimatorController.layers

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public var layers: AnimatorControllerLayer[];
public AnimatorControllerLayer[] layers;

Description

The layers in the controller.

It's important to note that the AnimatorControllerLayer are returned as a copy. The array should be set back into the property when changed.

#pragma strict
class ControllerModifier {
	var controller: UnityEditor.Animations.AnimatorController;
	public function ModifyLayers(layerIndex: int, newName: String) {
		var layers: UnityEditor.Animations.AnimatorControllerLayer[] = controller.layers;
		layers[layerIndex].name = newName;
		controller.layers = layers;
	}
}
class ControllerModifier
{
 	UnityEditor.Animations.AnimatorController controller; 	

public void ModifyLayers(int layerIndex, string newName) { UnityEditor.Animations.AnimatorControllerLayer[] layers = controller.layers; layers[layerIndex].name = newName; controller.layers = layers; } }