Example #1
0
        private static void DrawSelectRandomState(PlayRandomClip state, ref bool markDirty)
        {
            EditorGUILayout.LabelField("Select randomly from:");
            EditorGUI.indentLevel++;
            for (var i = 0; i < state.clips.Count; i++)
            {
                var oldClip = state.clips[i];

                state.clips[i] = EditorUtilities.ObjectField("Clip", oldClip, 150f, 200f);
                if (state.clips[i] != oldClip)
                {
                    state.OnClipAssigned(state.clips[i]);
                    markDirty = true;
                }
            }
            EditorGUI.indentLevel--;

            GUILayout.Space(10f);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add new choice", GUILayout.Width(150f)))
            {
                state.clips.Add(null);
                markDirty = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Example #2
0
        public static PlayRandomClip Create(string name)
        {
            var state = new PlayRandomClip();

            state.Initialize(name, DefaultName);
            return(state);
        }
Example #3
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();
            }
        }