void RefreshPanelChoices() { m_GraphViewChoices.Clear(); var usedGraphViews = new HashSet <GraphView>(); foreach (var toolWindow in GraphViewStaticBridge.GetGraphViewWindows <GraphViewToolWindow>(GetType())) { if (toolWindow.m_SelectedGraphView != null) { usedGraphViews.Add(toolWindow.m_SelectedGraphView); } } foreach (var window in GraphViewStaticBridge.GetGraphViewWindows <GraphViewEditorWindow>(null)) { int idx = 0; foreach (var graphView in window.graphViews.Where(IsGraphViewSupported)) { m_GraphViewChoices.Add(new GraphViewChoice { window = window, idx = idx++, graphView = graphView, canUse = !usedGraphViews.Contains(graphView) }); } } var menu = m_SelectorMenu.menu; var menuItemsCount = menu.MenuItems().Count; // Clear previous items (but not the "none" one at the top of the list) for (int i = menuItemsCount - 1; i > 0; i--) { menu.RemoveItemAt(i); } foreach (var graphView in m_GraphViewChoices) { menu.AppendAction(graphView.graphView.name, OnSelectGraphView, a => { var gvc = (GraphViewChoice)a.userData; return(gvc.graphView == m_SelectedGraphView ? DropdownMenuAction.Status.Checked : (gvc.canUse ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled)); }, graphView); } }