protected static void HandleReferencing(IReferencable p_reference, FieldInfo p_fieldInfo, bool p_directExpression = false, Parameter p_parameter = null) { if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.button == 1 && Event.current.type == EventType.MouseDown) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); menu.AddItem(new GUIContent("Copy reference"), false, () => { DashEditorCore.propertyReference = "[$" + p_reference.Id + "." + p_fieldInfo.Name + "]"; }); if (p_parameter != null && !string.IsNullOrEmpty(DashEditorCore.propertyReference)) { menu.AddItem(new GUIContent("Paste reference"), false, () => { p_parameter.isExpression = true; p_parameter.expression = DashEditorCore.propertyReference; }); } if (p_directExpression && !string.IsNullOrEmpty(DashEditorCore.propertyReference)) { menu.AddItem(new GUIContent("Paste reference"), false, () => { p_fieldInfo.SetValue(p_reference, DashEditorCore.propertyReference); }); } //menu.ShowAsContext(); GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false, false); } }
public static GenericMenuPopup Show(RuntimeGenericMenu p_menu, string p_title, Vector2 p_position, int p_width = 200, int p_height = 200, bool p_showSearch = true, bool p_showTooltip = true) { var popup = new GenericMenuPopup(p_menu, p_title); popup.width = p_width; popup.height = p_height; popup.showSearch = p_showSearch; popup.showTooltip = p_showTooltip; popup.showTitle = !string.IsNullOrEmpty(p_title); PopupWindow.Show(new Rect(p_position.x, p_position.y, 0, 0), popup); return(popup); }
public static GenericMenuPopup Get(RuntimeGenericMenu p_menu, string p_title) { var popup = new GenericMenuPopup(p_menu, p_title); return(popup); }