public static void SelectAnimationClip(AnimationClip clip) { if (AnimationWindow == null || clip == null) { return; } AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(Selection.activeGameObject); int index = 0; while (index < animationClips.Length) { if (animationClips[index] == clip) { break; } index++; } if (index == animationClips.Length) { Debug.LogError("Couldn't find clip " + clip.name); } else { ActiveAnimationClipProperty.SetValue(GetState(), clip, null); } AnimationWindow.Repaint(); }
public static void SelectAnimationClip(AnimationClip clip) { if (AnimationWindow == null || clip == null) { return; } AnimationClip[] clips = AnimationUtility.GetAnimationClips(Selection.activeGameObject); int index = 0; for ( ; index != clips.Length; ++index) { if (clips[index] == clip) { break; } } if (index == clips.Length) { // didn't find Debug.LogError("Couldn't find clip " + clip.name); } else { // found #if UNITY_5_0 object[] selectedAnimation = (object[])SelectedAnimationField.GetValue(AnimationWindow); if (selectedAnimation.Length > 0) { ChooseClipMethod.Invoke(selectedAnimation[0], new object[] { clip }); } #else ActiveAnimationClipProperty.SetValue(GetState(), clip, null); #endif } }