/************************************************************************************************************************/ #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(); }
/************************************************************************************************************************/ #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(); }