Return all StateMachineBehaviour that match type T
or derived from T
. Return null if none are found.
#pragma strict // An example StateMachineBehaviour. public class BreathBehaviour extends StateMachineBehaviour { public var fastBreath; // OnStateUpdate is called at each Update frame between OnStateEnter and OnStateExit callback public override function OnStateUpdate(animator, stateInfo, layerIndex) { animator.SetBool("FastBreath", fastBreath); } } public class RunBehaviour extends StateMachineBehaviour { // OnStateUpdate is called at each Update frame between OnStateEnter and OnStateExit callback public override function OnStateUpdate(animator, stateInfo, layerIndex) { var breathBehaviours = animator.GetBehaviours.<BreathBehaviour>(); for (var i = 0; i < breathBehaviours.Length(); i++) breathBehaviours[i].fastBreath = true; } }
using UnityEngine; using System.Collections;
// An example StateMachineBehaviour. public class BreathBehaviour : StateMachineBehaviour {
public bool fastBreath;
// OnStateUpdate is called at each Update frame between OnStateEnter and OnStateExit callback override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animator.SetBool("FastBreath", fastBreath); } }
public class RunBehaviour : StateMachineBehaviour { // OnStateUpdate is called at each Update frame between OnStateEnter and OnStateExit callback override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { BreathBehaviour[] breathBehaviours = animator.GetBehaviours<BreathBehaviour>(); for(int i=0;i<breathBehaviours.Length();i++) breathBehaviours[i].fastBreath = true; } }