示例#1
0
        private void RefreshPanelChoices()
        {
            m_PanelChoices.Clear();
            m_PanelToEditorWindow.Clear();
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                // Skip this window
                GUIView  view     = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                HostView hostView = view as HostView;
                if (hostView != null && hostView.actualView == this)
                {
                    continue;
                }

                var p = it.Current.Value;
                m_PanelChoices.Add(new PanelChoice(p));
                if (hostView != null && hostView.actualView != null)
                {
                    m_PanelToEditorWindow.Add(p, hostView.actualView);
                }
            }

            var menu           = m_PanelSelect.menu;
            var menuItemsCount = menu.MenuItems().Count;

            // Clear previous items
            for (int i = 0; i < menuItemsCount; i++)
            {
                menu.RemoveItemAt(0);
            }

            foreach (var panelChoice in m_PanelChoices)
            {
                menu.AppendAction(panelChoice.ToString(), OnSelectPanel, DropdownMenuAction.AlwaysEnabled, panelChoice);
            }
        }
示例#2
0
        protected virtual void PopulatePanelChoices(List <IPanelChoice> panelChoices)
        {
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                // Skip this debugger window
                GUIView  view     = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                HostView hostView = view as HostView;
                if (!m_DebuggerWindow.CanDebugView(hostView))
                {
                    continue;
                }

                var p = it.Current.Value;
                panelChoices.Add(new PanelChoice(p));
            }
        }
        void RefreshPanelChoices()
        {
            m_GraphViewChoices.Clear();

            var guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);

            var usedGraphViews = new HashSet <GraphView>();

            // Get all GraphViews used by existing tool windows of our type
            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                var currentWindowType = GetType();
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    foreach (var graphViewTool in dockArea.m_Panes.Where(p => p.GetType() == currentWindowType).Cast <GraphViewToolWindow>())
                    {
                        if (graphViewTool.m_SelectedGraphView != null)
                        {
                            usedGraphViews.Add(graphViewTool.m_SelectedGraphView);
                        }
                    }
                }
            }


            // Get all the existing GraphViewWindows we could use...
            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    foreach (var graphViewWindow in dockArea.m_Panes.OfType <GraphViewEditorWindow>())
                    {
                        int idx = 0;
                        foreach (var graphView in graphViewWindow.graphViews.Where(IsGraphViewSupported))
                        {
                            m_GraphViewChoices.Add(new GraphViewChoice {
                                window = graphViewWindow, 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);
            }
        }
 public static void StopDebugging()
 {
     GUIViewDebuggerHelper.StopDebugging();
 }
 public static void DebugWindow(GUIViewProxy guiViewProxy)
 {
     GUIViewDebuggerHelper.DebugWindow(guiViewProxy.guiView);
 }