Пример #1
0
        public static SingleClip Create(string name, AnimationClip clip = null)
        {
            var state = new SingleClip();

            state.Initialize(name, DefaultName);
            state.clip = clip;
            return(state);
        }
Пример #2
0
        private static void DrawSingleClipState(SingleClip state, ref bool markDirty, float labelWidth)
        {
            var oldClip = state.clip;

            state.clip = EditorUtilities.ObjectField("Clip", state.clip, labelWidth);
            if (state.clip != oldClip)
            {
                state.OnClipAssigned(state.clip);
                markDirty = true;
            }
        }
Пример #3
0
        private static void AddClipsAsSeperateStates(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;

            foreach (var clip in animationClips)
            {
                var newStateName = GetUniqueStateName(clip.name, layer.states);
                var newState     = SingleClip.Create(newStateName, clip);
                layer.states.Add(newState);
            }

            selectedState.SetTo(numClipsBefore);

            editor.MarkDirty();
        }
Пример #4
0
        private static void DrawAddStateButtons(AnimationPlayer animationPlayer, PersistedInt selectedState, AnimationPlayerEditor editor, AnimationLayer layer)
        {
            if (GUILayout.Button("Single Clip", buttonWidth))
            {
                EditorUtilities.RecordUndo(animationPlayer, "Add state to animation player");
                layer.states.Add(SingleClip.Create(GetUniqueStateName(SingleClip.DefaultName, layer.states)));
                selectedState.SetTo(layer.states.Count - 1);
                editor.MarkDirty();
            }

            if (GUILayout.Button("Play Random Clip", buttonWidth))
            {
                EditorUtilities.RecordUndo(animationPlayer, "Add random state to animation player");
                layer.states.Add(PlayRandomClip.Create(GetUniqueStateName(PlayRandomClip.DefaultName, layer.states)));
                selectedState.SetTo(layer.states.Count - 1);
                editor.MarkDirty();
            }

            if (GUILayout.Button("Sequence", buttonWidth))
            {
                EditorUtilities.RecordUndo(animationPlayer, "Add sequence to animation player");
                layer.states.Add(Sequence.Create(GetUniqueStateName(Sequence.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();
            }
        }