Exemple #1
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");
        }
Exemple #2
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);
        }