Пример #1
0
            public static void CrossFadeQueued(AnimancerState state)
            {
                CleanUp();

                var layer = state.Layer;

                // If the layer has no current state, just play the animation immediately.
                if (!layer.CurrentState.IsValid() || layer.CurrentState.Weight == 0)
                {
                    var fadeDuration = state.CalculateEditorFadeDuration(AnimancerPlayable.DefaultFadeDuration);
                    layer.Play(state, fadeDuration);
                    return;
                }

                AnimationQueue queue;

                if (!PlayableToQueue.TryGetValue(layer, out queue))
                {
                    queue = new AnimationQueue();
                    PlayableToQueue.Add(layer, queue);
                }

                queue.Queue.Add(state);

                layer.CurrentState.Events.OnEnd -= queue.PlayNext;
                layer.CurrentState.Events.OnEnd += queue.PlayNext;
            }
Пример #2
0
        /************************************************************************************************************************/
        #region Context Menu
        /************************************************************************************************************************/

        /// <summary>Adds functions relevant to the <see cref="AnimancerNodeDrawer{T}.Target"/>.</summary>
        protected override void PopulateContextMenu(GenericMenu menu)
        {
            AddContextMenuFunctions(menu);

            AnimancerEditorUtilities.AddMenuItem(menu, "Play",
                                                 !Target.IsPlaying || Target.Weight != 1,
                                                 () =>
            {
                Target.Root.UnpauseGraph();
                Target.Root.Play(Target);
            });

            AnimancerEditorUtilities.AddFadeFunction(menu, "Cross Fade (Ctrl + Click)",
                                                     Target.Weight != 1,
                                                     Target, (duration) =>
            {
                Target.Root.UnpauseGraph();
                Target.Root.Play(Target, duration);
            });

            AnimancerEditorUtilities.AddFadeFunction(menu, "Cross Fade Queued (Ctrl + Shift + Click)",
                                                     Target.Weight != 1,
                                                     Target, (duration) =>
            {
                AnimationQueue.CrossFadeQueued(Target);
            });

            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Destroy State"), false, () => Target.Destroy());

            menu.AddSeparator("");
            AnimancerEditorUtilities.AddDocumentationLink(menu, "State Documentation", "/docs/manual/states");
        }
Пример #3
0
        /************************************************************************************************************************/

        /// <summary>
        /// Handles Ctrl + Click on the label to CrossFade the animation.
        /// <para></para>
        /// If Shift is also held, the effect will be queued until after the previous animation finishes.
        /// </summary>
        private void HandleLabelClick(Rect area)
        {
            var currentEvent = Event.current;

            if (currentEvent.type != EventType.MouseUp ||
                !currentEvent.control ||
                !area.Contains(currentEvent.mousePosition))
            {
                return;
            }

            currentEvent.Use();

            if (currentEvent.shift)
            {
                AnimationQueue.CrossFadeQueued(Target);
                return;
            }

            AnimationQueue.ClearQueue(Target.Layer);

            Target.Root.UnpauseGraph();
            var fadeDuration = Target.CalculateEditorFadeDuration(AnimancerPlayable.DefaultFadeDuration);

            Target.Root.Play(Target, fadeDuration);
        }