private void ShowTextEditorPopupMenu(IInspector inspector) { var menu = Menu.Create(); if (editor.hasSelection && !editor.isPasswordField) { menu.Add("Cut", () => { Clipboard.Copy(editor.SelectedText); editor.DeleteSelection(); }); menu.Add("Copy", () => Clipboard.Copy(editor.SelectedText)); } if (editor.CanPaste()) { menu.Add("Paste", () => editor.Paste()); } var searchBox = inspector.Toolbar.GetItemByType(typeof(ISearchBoxToolbarItem)); if (searchBox != null && inspector.Manager.MouseoveredInspectorPart == InspectorPart.Toolbar || inspector.Manager.SelectedInspectorPart == InspectorPart.Toolbar) { ContextMenuUtility.Open(menu, true, inspector, InspectorPart.Toolbar, null, searchBox); } else { #if DEV_MODE Debug.LogWarning("Filter.ShowTextEditorPopupMenu called but subject was not ISearchBoxToolbarItem on inspector toolbar. Calling ContextMenuUtility with a null subject."); #endif ContextMenuUtility.Open(menu, null); } }
private void DisplayTargetSelectMenu() { var menu = Menu.Create(); menu.Add("Clear", SetValueFromMenu, Color.clear); menu.Add("White", SetValueFromMenu, Color.white); menu.Add("Black", SetValueFromMenu, Color.black); menu.Add("Gray", SetValueFromMenu, Color.gray); menu.Add("Red", SetValueFromMenu, Color.red); menu.Add("Yellow", SetValueFromMenu, Color.yellow); menu.Add("Blue", SetValueFromMenu, Color.blue); menu.Add("Green", SetValueFromMenu, Color.green); menu.Add("Cyan", SetValueFromMenu, Color.cyan); menu.Add("Magenta", SetValueFromMenu, Color.magenta); ContextMenuUtility.Open(menu, this); }
/// <inheritdoc/> public override bool DrawPrefix(Rect position) { if (Event.current.type == EventType.Repaint) { //hide prefix resizer line behind the field DrawGUI.Active.ColorRect(lastDrawPosition, DrawGUI.Active.InspectorBackgroundColor); if (backgroundRect.width > 0f) { GUI.Label(backgroundRect, "", InspectorPreferences.Styles.MethodBackground); } } bool drawBackgroundBehindFoldoutsWas = DrawGUI.drawBackgroundBehindFoldouts; DrawGUI.drawBackgroundBehindFoldouts = false; var prefixDrawRect = PrefixLabelPosition; var clipLabelInsideRect = prefixDrawRect; clipLabelInsideRect.width += clipLabelInsideRect.x; clipLabelInsideRect.x = 0f; prefixDrawRect.y = 0f; //use BeginArea to prevent foldout text clipping past the Button GUILayout.BeginArea(clipLabelInsideRect); bool dirty = base.DrawPrefix(prefixDrawRect); GUILayout.EndArea(); DrawGUI.drawBackgroundBehindFoldouts = drawBackgroundBehindFoldoutsWas; bool selected = Selected; var guiColorWas = GUI.color; bool isInvoking; if (isCoroutine && Application.isPlaying) { if (monoBehaviour != null) { isInvoking = monoBehaviour.IsInvoking(memberInfo.MethodInfo.Name); } else { isInvoking = StaticCoroutine.IsInvoking(memberInfo.MethodInfo.Name); } } else { isInvoking = false; } if (isInvoking) { GUI.color = Color.green; } else if (selected) { var col = preferences.theme.ButtonSelected; GUI.color = col; } if (GUI.Button(buttonRect, buttonLabel, Style)) { DrawGUI.UseEvent(); if (Event.current.button == 0) { dirty = true; Invoke(); Select(ReasonSelectionChanged.ControlClicked); } else if (Event.current.button == 1) { var menu = Menu.Create(); menu.Add(Menu.Item("Invoke", () => Invoke(false, false, false, false))); if (hasReturnValue) { #if !POWER_INSPECTOR_LITE menu.AddSeparator(); menu.Add(Menu.Item("Copy Return Value", () => Invoke(false, false, true, false))); #endif if (UnityObjectExtensions.IsUnityObjectOrUnityObjectCollectionType(Type)) { menu.Add(Menu.Item("Ping Return Value", () => Invoke(true, false, false, false))); menu.Add(Menu.Item("Select Return Value", () => Invoke(false, false, false, true))); } } if (isCoroutine) { menu.AddSeparator(); var monoBehaviour = UnityObject as MonoBehaviour; string methodName = MethodInfo.Name; if (monoBehaviour != null && Application.isPlaying) { menu.Add("Invoke Repeating/Every Second", () => monoBehaviour.InvokeRepeating(MethodInfo.Name, 1f, 1f)); menu.Add("Invoke Repeating/Every 5 Seconds", () => monoBehaviour.InvokeRepeating(MethodInfo.Name, 5f, 5f)); menu.Add("Invoke Repeating/Every 10 Seconds", () => monoBehaviour.InvokeRepeating(MethodInfo.Name, 10f, 10f)); if (monoBehaviour.IsInvoking(methodName)) { menu.Add("Stop Coroutine", () => monoBehaviour.StopCoroutine(MethodInfo.Name)); menu.Add("Cancel Invoke", () => monoBehaviour.CancelInvoke(MethodInfo.Name)); } } } ContextMenuUtility.Open(menu, this); } else if (Event.current.button == 2) { Invoke(true, false, true, false); } } GUI.color = guiColorWas; return(dirty); }