public static bool AddClipToAnimatorComponent(Animator animator, AnimationClip newClip) { UnityEditor.Animations.AnimatorController animatorController = UnityEditor.Animations.AnimatorController.GetEffectiveAnimatorController(animator); if (animatorController == null) { animatorController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerForClip(newClip, animator.gameObject); UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, animatorController); return(animatorController != null); } ChildAnimatorState childAnimatorState = animatorController.layers[0].stateMachine.FindState(newClip.name); if (childAnimatorState.Equals(default(ChildAnimatorState))) { animatorController.AddMotion(newClip); } else if (childAnimatorState.state && childAnimatorState.state.motion == null) { childAnimatorState.state.motion = newClip; } else if (childAnimatorState.state && childAnimatorState.state.motion != newClip) { animatorController.AddMotion(newClip); } return(true); }
public static bool AddClipToAnimatorComponent(Animator animator, AnimationClip newClip) { UnityEditor.Animations.AnimatorController animatorController = UnityEditor.Animations.AnimatorController.GetEffectiveAnimatorController(animator); if ((UnityEngine.Object)animatorController == (UnityEngine.Object)null) { UnityEditor.Animations.AnimatorController controllerForClip = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerForClip(newClip, animator.gameObject); UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, controllerForClip); return((UnityEngine.Object)controllerForClip != (UnityEngine.Object)null); } ChildAnimatorState state = animatorController.layers[0].stateMachine.FindState(newClip.name); if (state.Equals((object)new ChildAnimatorState())) { animatorController.AddMotion((Motion)newClip); } else if ((bool)((UnityEngine.Object)state.state) && (UnityEngine.Object)state.state.motion == (UnityEngine.Object)null) { state.state.motion = (Motion)newClip; } else if ((bool)((UnityEngine.Object)state.state) && (UnityEngine.Object)state.state.motion != (UnityEngine.Object)newClip) { animatorController.AddMotion((Motion)newClip); } return(true); }
public static bool AddClipToAnimatorComponent(Animator animator, AnimationClip newClip) { AnimatorController effectiveAnimatorController = AnimatorController.GetEffectiveAnimatorController(animator); if (effectiveAnimatorController == null) { effectiveAnimatorController = AnimatorController.CreateAnimatorControllerForClip(newClip, animator.gameObject); AnimatorController.SetAnimatorController(animator, effectiveAnimatorController); return(effectiveAnimatorController != null); } ChildAnimatorState state = effectiveAnimatorController.layers[0].stateMachine.FindState(newClip.name); if (state.Equals(new ChildAnimatorState())) { effectiveAnimatorController.AddMotion(newClip); } else if ((state.state != null) && (state.state.motion == null)) { state.state.motion = newClip; } else if ((state.state != null) && (state.state.motion != newClip)) { effectiveAnimatorController.AddMotion(newClip); } return(true); }