private void DrawMoreMenu(SearchSelection selection, IEnumerable <SearchAction> actions) { if (!actions.Any()) { return; } if (GUILayout.Button(Styles.moreActionsContent, GUILayout.Height(20f), GUILayout.Width(24f))) { var menu = new GenericMenu(); foreach (var action in actions) { if (action == null || action.content == null) { continue; } if (selection.Count > 1 && action.execute == null) { continue; } var itemName = !string.IsNullOrWhiteSpace(action.content.text) ? action.content.text : action.content.tooltip; menu.AddItem(new GUIContent(itemName, action.content.image), false, () => m_SearchView.ExecuteAction(action, selection.ToArray(), false)); } menu.ShowAsContext(); } }
private void SetupEditors(SearchSelection selection, ShowDetailsOptions showOptions) { int selectionHash = 0; foreach (var s in selection) { selectionHash ^= s.id.GetHashCode(); } if (selectionHash == m_EditorsHash) { return; } ResetEditors(); if (!showOptions.HasAny(ShowDetailsOptions.Inspector)) { return; } var targets = new List <UnityEngine.Object>(); foreach (var s in selection) { var item = s; LoadEditor(item, targets); if (item.GetFieldCount() > 0) { targets.Add(new SearchServiceItem() { name = item.label ?? item.value.ToString(), item = item }); } } if (targets.Count > 0) { int maxGroupCount = targets.GroupBy(t => t.GetType()).Max(g => g.Count()); m_Editors = targets.GroupBy(t => t.GetType()).Where(g => g.Count() == maxGroupCount).Select(g => { var editor = Editor.CreateEditor(g.ToArray()); Utils.SetFirstInspectedEditor(editor); return(editor); }).ToArray(); } m_EditorsHash = selectionHash; }
private void DrawActions(SearchSelection selection, IEnumerable <SearchAction> actions) { foreach (var action in actions) { if (action == null || action.content == null) { continue; } if (selection.Count > 1 && action.execute == null) { continue; } if (GUILayout.Button(action.content, GUILayout.Height(20f), GUILayout.ExpandWidth(true))) { m_SearchView.ExecuteAction(action, selection.ToArray(), false); GUIUtility.ExitGUI(); } } }