private static void AddClipsAsBlendTree(AnimationPlayer animationPlayer, PersistedInt selectedLayer, PersistedInt selectedState, AnimationPlayerEditor editor, List <AnimationClip> animationClips) { EditorUtilities.RecordUndo(animationPlayer, "Added clip to Animation Player"); var layer = animationPlayer.layers[selectedLayer]; int numClipsBefore = layer.states.Count; var newStateName = GetUniqueStateName(BlendTree1D.DefaultName, layer.states); var newState = BlendTree1D.Create(newStateName); foreach (var clip in animationClips) { var newEntry = new BlendTreeEntry1D { clip = clip }; newState.blendTree.Add(newEntry); } layer.states.Add(newState); selectedState.SetTo(numClipsBefore); editor.MarkDirty(); }
private static void DrawAddStateButtons(AnimationPlayer animationPlayer, PersistedInt selectedState, AnimationPlayerEditor editor, AnimationLayer layer) { if (GUILayout.Button("Single Clip State", buttonWidth)) { EditorUtilities.RecordUndo(animationPlayer, "Add state to animation player"); layer.states.Add(SingleClipState.Create(GetUniqueStateName(SingleClipState.DefaultName, layer.states))); selectedState.SetTo(layer.states.Count - 1); editor.MarkDirty(); } if (GUILayout.Button("1D Blend Tree", buttonWidth)) { EditorUtilities.RecordUndo(animationPlayer, "Add blend tree to animation player"); layer.states.Add(BlendTree1D.Create(GetUniqueStateName(BlendTree1D.DefaultName, layer.states))); selectedState.SetTo(layer.states.Count - 1); editor.MarkDirty(); } if (GUILayout.Button("2D Blend Tree", buttonWidth)) { EditorUtilities.RecordUndo(animationPlayer, "Add 2D blend tree to animation player"); layer.states.Add(BlendTree2D.Create(GetUniqueStateName(BlendTree2D.DefaultName, layer.states))); selectedState.SetTo(layer.states.Count - 1); editor.MarkDirty(); } }