var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ("Assets/Mecanim/StateMachineTransitions.controller");
controller.AddParameter(“TransitionNow”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“Reset”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“GotoB1″, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“GotoC”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
var rootStateMachine = controller.layers[0].stateMachine;
var stateMachineA = rootStateMachine.AddStateMachine(“smA”);
var stateMachineB = rootStateMachine.AddStateMachine(“smB”);
var stateMachineC = stateMachineB.AddStateMachine(“smC”);
var stateA1 = stateMachineA.AddState(“stateA1″);
var stateB1 = stateMachineB.AddState(“stateB1″);
var stateB2 = stateMachineB.AddState(“stateB2″);
stateMachineC.AddState(“stateC1″);
var stateC2 = stateMachineC.AddState(“stateC2″);
var exitTransition = stateA1.AddExitTransition();
exitTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
exitTransition.duration = 0;
var resetTransition = stateMachineA.AddAnyStateTransition(stateA1);
resetTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “Reset”);
resetTransition.duration = 0;
var transitionB1 = stateMachineB.AddEntryTransition(stateB1);
transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoB1″);
stateMachineB.AddEntryTransition(stateB2);
stateMachineC.defaultState = stateC2;
var exitTransitionC2 = stateC2.AddExitTransition();
exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
exitTransitionC2.duration = 0;
var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC);
stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoC”);
rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB);