Esempio n. 1
0
        /************************************************************************************************************************/
        #region Context Menu
        /************************************************************************************************************************/

        /// <inheritdoc/>
        protected override void PopulateContextMenu(GenericMenu menu)
        {
            menu.AddDisabledItem(new GUIContent($"{DetailsPrefix}{nameof(Target.CurrentState)}: {Target.CurrentState}"));
            menu.AddDisabledItem(new GUIContent($"{DetailsPrefix}{nameof(Target.CommandCount)}: {Target.CommandCount}"));

            menu.AddFunction("Stop",
                             HasAnyStates((state) => state.IsPlaying || state.Weight != 0),
                             () => Target.Stop());

            AnimancerEditorUtilities.AddFadeFunction(menu, "Fade In",
                                                     Target.Index > 0 && Target.Weight != 1, Target,
                                                     (duration) => Target.StartFade(1, duration));
            AnimancerEditorUtilities.AddFadeFunction(menu, "Fade Out",
                                                     Target.Index > 0 && Target.Weight != 0, Target,
                                                     (duration) => Target.StartFade(0, duration));

            AnimancerEditorUtilities.AddContextMenuIK(menu, Target);

            menu.AddSeparator("");

            menu.AddFunction("Destroy States",
                             ActiveStates.Count > 0 || InactiveStates.Count > 0,
                             () => Target.DestroyStates());

            AnimancerPlayableDrawer.AddRootFunctions(menu, Target.Root);

            menu.AddSeparator("");

            AnimancerPlayableDrawer.AddDisplayOptions(menu);

            AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", Strings.DocsURLs.Layers);

            menu.ShowAsContext();
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if the current event is a context menu click within the `clickArea` and opens a context menu with various
        /// functions for the <see cref="Target"/>.
        /// </summary>
        protected void CheckContextMenu(Rect clickArea)
        {
            if (!AnimancerGUI.TryUseClickEvent(clickArea, 1))
            {
                return;
            }

            var menu = new GenericMenu();

            menu.AddDisabledItem(new GUIContent(Target.ToString()));

            PopulateContextMenu(menu);

            menu.AddItem(new GUIContent(DetailsPrefix + "Log Details"), false,
                         () => Debug.Log(Target.GetDescription(), Target.Root?.Component as Object));

            menu.AddItem(new GUIContent(DetailsPrefix + "Log Details Of Everything"), false,
                         () => Debug.Log(Target.Root.GetDescription(), Target.Root?.Component as Object));
            AnimancerPlayableDrawer.AddPlayableGraphVisualizerFunction(menu, DetailsPrefix, Target.Root._Graph);

            menu.ShowAsContext();
        }