示例#1
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);
        }
示例#2
0
        public void Initialize(EditorWindow debuggerWindow, VisualElement root, DebuggerContext context)
        {
            base.Initialize(debuggerWindow);

            m_Root    = root;
            m_Context = context;
            m_Context.onStateChange += OnContextChange;

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

            m_Root.styleSheets.Add(sheet);

            StyleSheet colorSheet;

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

            m_Root.styleSheets.Add(colorSheet);

            m_Root.Add(m_Toolbar);

            m_PickToggle = new ToolbarToggle()
            {
                name = "pickToggle"
            };
            m_PickToggle.text = "Pick Element";
            m_PickToggle.RegisterValueChangedCallback((e) =>
            {
                m_Context.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_Context.selection.panel as Panel;
                    if (p != null)
                    {
                        TryFocusCorrespondingWindow(p.ownerObject);
                    }
                }
            });

            m_Toolbar.Add(m_PickToggle);

            m_ShowLayoutToggle = new ToolbarToggle()
            {
                name = "layoutToggle"
            };
            m_ShowLayoutToggle.text = "Show Layout";
            m_ShowLayoutToggle.RegisterValueChangedCallback((e) => { m_Context.showLayoutBound = e.newValue; });

            m_Toolbar.Add(m_ShowLayoutToggle);

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

                m_ShowDrawStatsToggle = new ToolbarToggle()
                {
                    name = "drawStatsToggle"
                };
                m_ShowDrawStatsToggle.text = "Draw Stats";
                m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) => { m_Context.showDrawStats = e.newValue; });
                m_Toolbar.Add(m_ShowDrawStatsToggle);
            }

            var splitter = new DebuggerSplitter();

            m_Root.Add(splitter);

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

            m_StylesDebuggerContainer = new StylesDebugger(m_Context.selection);
            splitter.rightPane.Add(m_StylesDebuggerContainer);

            DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this;

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

            OnContextChange();
        }