示例#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();
        }
示例#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
        /************************************************************************************************************************/
        #region Context Menu
        /************************************************************************************************************************/

        /// <summary>
        /// Checks if the current event is a context menu click within the `clickArea` and opens a context menu with various
        /// functions for the `playable`.
        /// </summary>
        private void CheckContextMenu(Rect clickArea, AnimancerPlayable playable)
        {
            if (!AnimancerGUI.TryUseClickEvent(clickArea, 1))
            {
                return;
            }

            var menu = new GenericMenu();

            menu.AddDisabledItem(new GUIContent(playable.Graph.GetEditorName() ?? "Unnamed Graph"), false);
            menu.AddDisabledItem(new GUIContent("Command Count: " + playable.CommandCount), false);
            menu.AddDisabledItem(new GUIContent("Frame ID: " + playable.FrameID), false);
            AddDisposablesFunctions(menu, playable.Disposables);

            AddUpdateModeFunctions(menu, playable);
            AnimancerEditorUtilities.AddContextMenuIK(menu, playable);
            AddRootFunctions(menu, playable);

            menu.AddSeparator("");

            AddDisplayOptions(menu);

            menu.AddItem(new GUIContent("Log Details Of Everything"), false,
                         () => Debug.Log(playable.GetDescription(), playable.Component as Object));
            AddPlayableGraphVisualizerFunction(menu, "", playable._Graph);

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

            menu.ShowAsContext();
        }
示例#4
0
        /************************************************************************************************************************/

        private void DoPlayableNotInitialisedGUI()
        {
            if (!EditorApplication.isPlaying)
            {
                return;
            }

            var target = _Targets[0];

            if (EditorUtility.IsPersistent(target.gameObject))
            {
                return;
            }

            EditorGUILayout.HelpBox("Playable is not initialised." +
                                    " It will be initialised automatically when something needs it, such as playing an animation.",
                                    MessageType.Info);

            var area = GUILayoutUtility.GetLastRect();

            AnimancerLayerDrawer.HandleDragAndDropAnimations(area, target, 0);

            if (!AnimancerEditorUtilities.TryUseContextClick(area))
            {
                return;
            }

            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Initialise"), false, () => target.Playable.GetLayer(0));

            AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/animation-layers");

            menu.ShowAsContext();
        }
        /************************************************************************************************************************/
        #region Context Menu
        /************************************************************************************************************************/

        /// <summary>Adds functions relevant to the <see cref="AnimancerNodeDrawer{T}.Target"/>.</summary>
        protected override void PopulateContextMenu(GenericMenu menu)
        {
            menu.AddDisabledItem(new GUIContent(DetailsPrefix + "CurrentState: " + Target.CurrentState));
            menu.AddDisabledItem(new GUIContent(DetailsPrefix + "CommandCount: " + Target.CommandCount));

            AnimancerEditorUtilities.AddMenuItem(menu, "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));

            menu.AddItem(new GUIContent("Inverse Kinematics/Apply Animator IK"),
                         Target.ApplyAnimatorIK,
                         () => Target.ApplyAnimatorIK = !Target.ApplyAnimatorIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Animator IK"),
                         Target.DefaultApplyAnimatorIK,
                         () => Target.DefaultApplyAnimatorIK = !Target.DefaultApplyAnimatorIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Apply Foot IK"),
                         Target.ApplyFootIK,
                         () => Target.ApplyFootIK = !Target.ApplyFootIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Foot IK"),
                         Target.DefaultApplyFootIK,
                         () => Target.DefaultApplyFootIK = !Target.DefaultApplyFootIK);

            menu.AddSeparator("");

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

            AnimancerEditorUtilities.AddMenuItem(menu, "Add Layer",
                                                 Target.Root.Layers.Count < AnimancerPlayable.LayerList.defaultCapacity,
                                                 () => Target.Root.Layers.Count++);
            AnimancerEditorUtilities.AddMenuItem(menu, "Remove Layer",
                                                 Target.Root.Layers.Count > 0,
                                                 () => Target.Root.Layers.Count--);

            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Keep Weightless Playables Connected"),
                         Target.Root.KeepChildrenConnected,
                         () => Target.Root.KeepChildrenConnected = !Target.Root.KeepChildrenConnected);

            AddPrefFunctions(menu);

            menu.AddSeparator("");

            AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/blending/layers");

            menu.ShowAsContext();
        }
        /// <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="State"/>.
        /// </summary>
        protected void CheckContextMenu(Rect clickArea)
        {
            if (!AnimancerEditorUtilities.TryUseContextClick(clickArea))
            {
                return;
            }

            var menu = new GenericMenu();

            menu.AddDisabledItem(new GUIContent(DetailsPrefix + "State: " + State.ToString()));

            var key = State.Key;

            if (key != null)
            {
                menu.AddDisabledItem(new GUIContent(DetailsPrefix + "Key: " + key));
            }

            AnimancerEditorUtilities.AddMenuItem(menu, "Play",
                                                 !State.IsPlaying || State.Weight != 1,
                                                 () => State.Root.Play(State));

            AnimancerEditorUtilities.AddFadeFunction(menu, "Cross Fade (Ctrl + Click)",
                                                     State.Weight != 1,
                                                     State, (duration) => State.Root.CrossFade(State, duration));

            AddContextMenuFunctions(menu);

            menu.AddItem(new GUIContent(DetailsPrefix + "Log Details"), false,
                         () => Debug.Log("AnimancerState: " + State.GetDescription(true)));

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

            menu.AddSeparator("");
            AnimancerEditorUtilities.AddDocumentationLink(menu, "State Documentation", "/docs/manual/animancer-states");

            menu.ShowAsContext();
        }
示例#7
0
        /************************************************************************************************************************/

        private void DoPlayableNotInitializedGUI(IAnimancerComponent target)
        {
            if (!EditorApplication.isPlaying ||
                target.Animator == null ||
                EditorUtility.IsPersistent(target.Animator))
            {
                return;
            }

            EditorGUILayout.HelpBox("Playable is not initialized." +
                                    " It will be initialized automatically when something needs it, such as playing an animation.",
                                    MessageType.Info);

            if (AnimancerGUI.TryUseClickEventInLastRect(1))
            {
                var menu = new GenericMenu();

                menu.AddItem(new GUIContent("Initialize"), false, () => target.Playable.Evaluate());

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

                menu.ShowAsContext();
            }
        }
示例#8
0
        /************************************************************************************************************************/
        #region Context Menu
        /************************************************************************************************************************/

        /// <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="Layer"/>.
        /// </summary>
        private void CheckContextMenu(Rect clickArea)
        {
            if (!AnimancerEditorUtilities.TryUseContextClick(clickArea))
            {
                return;
            }

            var menu = new GenericMenu();

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

            AnimancerEditorUtilities.AddMenuItem(menu, "Stop",
                                                 HasAnyStates((state) => state.IsPlaying || state.Weight != 0),
                                                 () => Layer.Stop());

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

            menu.AddItem(new GUIContent("Inverse Kinematics/Apply Animator IK"),
                         Layer.ApplyAnimatorIK,
                         () => Layer.ApplyAnimatorIK = !Layer.ApplyAnimatorIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Animator IK"),
                         Layer.DefaultApplyAnimatorIK,
                         () => Layer.DefaultApplyAnimatorIK = !Layer.DefaultApplyAnimatorIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Apply Foot IK"),
                         Layer.ApplyFootIK,
                         () => Layer.ApplyFootIK = !Layer.ApplyFootIK);
            menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Foot IK"),
                         Layer.DefaultApplyFootIK,
                         () => Layer.DefaultApplyFootIK = !Layer.DefaultApplyFootIK);

            menu.AddSeparator("");

            AnimancerEditorUtilities.AddMenuItem(menu, "Destroy States",
                                                 ActiveStates.Count > 0 || InactiveStates.Count > 0,
                                                 () => Layer.DestroyStates());

            AnimancerEditorUtilities.AddMenuItem(menu, "Add Layer",
                                                 Layer.Root.LayerCount < AnimancerPlayable.maxLayerCount,
                                                 () => Layer.Root.LayerCount++);
            AnimancerEditorUtilities.AddMenuItem(menu, "Remove Layer",
                                                 Layer.Root.LayerCount > 0,
                                                 () => Layer.Root.LayerCount--);

            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Keep Weightless Playables Connected"),
                         Layer.Root.KeepPlayablesConnected,
                         () => Layer.Root.KeepPlayablesConnected = !Layer.Root.KeepPlayablesConnected);

            AddPrefFunctions(menu);

            menu.AddSeparator("");

            AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/animation-layers");
            AddPlayableGraphVisualizerFunction(menu);

            menu.ShowAsContext();
        }