Пример #1
0
        public StylesDebugger(DebuggerSelection debuggerSelection)
        {
            m_DebuggerSelection = debuggerSelection;
            m_DebuggerSelection.onPanelDebugChanged      += pdbg => m_PanelDebug = pdbg;
            m_DebuggerSelection.onSelectedElementChanged += element => selectedElement = element;

            m_PanelDebug    = m_DebuggerSelection.panelDebug;
            selectedElement = m_DebuggerSelection.element;

            m_ScrollView = new ScrollView();

            m_BoxModelView = new BoxModelView();
            m_ScrollView.Add(m_BoxModelView);

            m_IMGUIStylesDebugger = new IMGUIContainer(OnGUI);
            m_ScrollView.Add(m_IMGUIStylesDebugger);
            Add(m_ScrollView);
        }
Пример #2
0
        public DebuggerTreeView(DebuggerSelection debuggerSelection, Action <VisualElement> selectElementCallback)
        {
            this.focusable = true;

            m_DebuggerSelection = debuggerSelection;
            m_DebuggerSelection.onPanelDebugChanged      += pdbg => RebuildTree(pdbg);
            m_DebuggerSelection.onSelectedElementChanged += element => SelectElement(element, null);

            m_SelectElementCallback = selectElementCallback;
            hierarchyHasChanged     = true;

            m_SearchResultsHightlights = new List <VisualElement>();

            this.RegisterCallback <FocusEvent>(e => m_TreeView?.Focus());

            m_TreeViewHoverOverlay = new HighlightOverlayPainter();

            m_Container = new VisualElement();
            m_Container.style.flexGrow = 1f;
            Add(m_Container);

            m_SearchBar = new DebuggerSearchBar(this);
            Add(m_SearchBar);
        }
Пример #3
0
        public new void OnEnable()
        {
            base.OnEnable();

            DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this;

            m_DebuggerSelection = new DebuggerSelection();
            m_RepaintOverlay    = new RepaintOverlayPainter();
            m_PickOverlay       = new HighlightOverlayPainter();
            m_LayoutOverlay     = new LayoutOverlayPainter();

            var root  = this.rootVisualElement;
            var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet;

            root.styleSheets.Add(sheet);

            StyleSheet colorSheet;

            if (EditorGUIUtility.isProSkin)
            {
                colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet;
            }
            else
            {
                colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet;
            }

            root.styleSheets.Add(colorSheet);
            root.Add(m_Toolbar);

            m_PickToggle = new ToolbarToggle()
            {
                name = "pickToggle"
            };
            m_PickToggle.text = "Pick Element";
            m_PickToggle.RegisterValueChangedCallback((e) =>
            {
                m_PickElement = e.newValue;
                // On OSX, as focus-follow-mouse is not supported,
                // we explicitly focus the EditorWindow when enabling picking
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    Panel p = m_DebuggerSelection.panel as Panel;
                    if (p != null)
                    {
                        TryFocusCorrespondingWindow(p);
                    }
                }
            });

            m_Toolbar.Add(m_PickToggle);

            m_ShowLayoutToggle = new ToolbarToggle()
            {
                name = "layoutToggle"
            };
            m_ShowLayoutToggle.SetValueWithoutNotify(m_ShowLayoutBound);
            m_ShowLayoutToggle.text = "Show Layout";
            m_ShowLayoutToggle.RegisterValueChangedCallback((e) =>
            {
                m_ShowLayoutBound = e.newValue;
                panelDebug?.MarkDirtyRepaint();
                panelDebug?.MarkDebugContainerDirtyRepaint();
            });

            m_Toolbar.Add(m_ShowLayoutToggle);

            if (Unsupported.IsDeveloperBuild())
            {
                m_RepaintOverlayToggle = new ToolbarToggle()
                {
                    name = "repaintOverlayToggle"
                };
                m_RepaintOverlayToggle.text = "Repaint Overlay";
                m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_ShowRepaintOverlay = e.newValue);
                m_Toolbar.Add(m_RepaintOverlayToggle);

                m_UXMLLiveReloadToggle = new ToolbarToggle()
                {
                    name = "UXMLReloadToggle"
                };
                m_UXMLLiveReloadToggle.SetValueWithoutNotify(RetainedMode.UxmlLiveReloadIsEnabled);
                m_UXMLLiveReloadToggle.text = "UXML Live Reload";
                m_UXMLLiveReloadToggle.RegisterValueChangedCallback((e) => RetainedMode.UxmlLiveReloadIsEnabled = e.newValue);
                m_Toolbar.Add(m_UXMLLiveReloadToggle);

                m_ShowDrawStatsToggle = new ToolbarToggle()
                {
                    name = "drawStatsToggle"
                };
                m_ShowDrawStatsToggle.text = "Draw Stats";
                m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) =>
                {
                    var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater;
                    if (updater != null)
                    {
                        updater.DebugGetRenderChain().drawStats = e.newValue;
                    }
                    panelDebug?.MarkDirtyRepaint();
                });
                m_Toolbar.Add(m_ShowDrawStatsToggle);
            }

            var splitter = new DebuggerSplitter();

            root.Add(splitter);

            m_TreeViewContainer = new DebuggerTreeView(m_DebuggerSelection, SelectElement);
            m_TreeViewContainer.style.flexGrow = 1f;
            splitter.leftPane.Add(m_TreeViewContainer);

            m_StylesDebuggerContainer = new StylesDebugger(m_DebuggerSelection);
            splitter.rightPane.Add(m_StylesDebuggerContainer);
        }