コード例 #1
0
        protected override void OnSelectPanelDebug(IPanelDebug pdbg)
        {
            m_RepaintOverlay.ClearOverlay();

            m_TreeViewContainer.hierarchyHasChanged = true;
            if (m_Context.panelDebug?.debugContainer != null)
            {
                m_Context.panelDebug.debugContainer.generateVisualContent -= OnGenerateVisualContent;
            }

            m_Context.selection.panelDebug = pdbg;

            if (panelDebug?.debugContainer != null)
            {
                panelDebug.debugContainer.generateVisualContent += OnGenerateVisualContent;
            }

            Refresh();
        }
コード例 #2
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);

            m_StylePropertyDebugger = new StylePropertyDebugger(selectedElement);
            m_ScrollView.Add(m_StylePropertyDebugger);

            Add(m_ScrollView);
        }
コード例 #3
0
        private static bool DoDispatch(BaseVisualElementPanel panel)
        {
            bool result = false;
            bool flag   = UIElementsUtility.s_EventInstance.type == EventType.Repaint;

            if (flag)
            {
                using (UIElementsUtility.s_RepaintProfilerMarker.Auto())
                {
                    panel.Repaint(UIElementsUtility.s_EventInstance);
                }
                IPanelDebug expr_46 = panel.panelDebug;
                Panel       expr_57 = ((expr_46 != null) ? expr_46.debuggerOverlayPanel : null) as Panel;
                if (expr_57 != null)
                {
                    expr_57.Repaint(UIElementsUtility.s_EventInstance);
                }
                result = (panel.IMGUIContainersCount > 0);
            }
            else
            {
                panel.ValidateLayout();
                using (EventBase eventBase = UIElementsUtility.CreateEvent(UIElementsUtility.s_EventInstance))
                {
                    bool flag2 = UIElementsUtility.s_EventInstance.type == EventType.Used || UIElementsUtility.s_EventInstance.type == EventType.Layout || UIElementsUtility.s_EventInstance.type == EventType.ExecuteCommand || UIElementsUtility.s_EventInstance.type == EventType.ValidateCommand;
                    using (UIElementsUtility.s_EventProfilerMarker.Auto())
                    {
                        panel.SendEvent(eventBase, flag2 ? DispatchMode.Immediate : DispatchMode.Default);
                    }
                    bool isPropagationStopped = eventBase.isPropagationStopped;
                    if (isPropagationStopped)
                    {
                        panel.visualTree.IncrementVersion(VersionChangeType.Repaint);
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        public override void Repaint(Event e)
        {
            bool flag = this.contextType == ContextType.Editor;

            if (flag)
            {
                UnityEngine.Debug.Assert(GUIClip.Internal_GetCount() == 0, "UIElement is not compatible with IMGUI GUIClips, only GUIClip.ParentClipScope");
            }
            this.m_RepaintVersion = this.version;
            bool flag2 = this.contextType == ContextType.Editor;

            if (flag2)
            {
                base.pixelsPerPoint = GUIUtility.pixelsPerPoint;
            }
            this.repaintData.repaintEvent = e;
            using (this.m_MarkerBeforeUpdate.Auto())
            {
                base.InvokeBeforeUpdate();
            }
            Action <Panel> expr_7E = Panel.beforeAnyRepaint;

            if (expr_7E != null)
            {
                expr_7E(this);
            }
            using (this.m_MarkerUpdate.Auto())
            {
                this.UpdateForRepaint();
            }
            IPanelDebug expr_B7 = base.panelDebug;

            if (expr_B7 != null)
            {
                expr_B7.Refresh();
            }
        }
コード例 #5
0
        protected virtual void Dispose(bool disposing)
        {
            bool disposed = this.disposed;

            if (!disposed)
            {
                if (disposing)
                {
                    bool flag = this.panelDebug != null;
                    if (flag)
                    {
                        this.panelDebug.DetachAllDebuggers();
                        this.panelDebug = null;
                    }
                    bool flag2 = this.ownerObject != null;
                    if (flag2)
                    {
                        UIElementsUtility.RemoveCachedPanel(this.ownerObject.GetInstanceID());
                    }
                }
                this.yogaConfig = null;
                this.disposed   = true;
            }
        }
コード例 #6
0
 protected virtual void OnSelectPanelDebug(IPanelDebug pdbg)
 {
 }
コード例 #7
0
        public void RebuildTree(IPanelDebug panelDebug)
        {
            if (!hierarchyHasChanged && m_CurrentPanelDebug == panelDebug)
            {
                return;
            }

            m_CurrentPanelDebug = panelDebug;
            m_Container.Clear();

            int nextId = 1;

            m_TreeRootItems.Clear();

            var visualTree = panelDebug?.visualTree;

            if (visualTree != null)
            {
                var rootItem = new TreeViewItem <VisualElement>(nextId++, visualTree);
                m_TreeRootItems.Add(rootItem);

                var childItems = new List <ITreeViewItem>();
                AddTreeItemsForElement(childItems, visualTree, ref nextId);

                rootItem.AddChildren(childItems);
            }

            Func <VisualElement> makeItem = () =>
            {
                var element = new VisualElement();
                element.name = "unity-treeview-item-content";
                element.RegisterCallback <MouseEnterEvent>((e) =>
                {
                    HighlightItemInTargetWindow(e.target as VisualElement);
                });
                element.RegisterCallback <MouseLeaveEvent>((e) =>
                {
                    UnhighlightItemInTargetWindow(e.target as VisualElement);
                });
                return(element);
            };

            // Clear selection which would otherwise persist via view data persistence.
            m_TreeView?.ClearSelection();

            m_TreeView = new TreeView(m_TreeRootItems, 20, makeItem, FillItem);
            m_TreeView.style.flexGrow     = 1;
            m_TreeView.onSelectionChange += items =>
            {
                if (m_SelectElementCallback == null)
                {
                    return;
                }

                if (!items.Any())
                {
                    m_SelectElementCallback(null);
                    return;
                }

                var item    = items.First() as TreeViewItem <VisualElement>;
                var element = item != null ? item.data : null;
                m_SelectElementCallback(element);
            };

            m_Container.Add(m_TreeView);

            hierarchyHasChanged = false;
        }
コード例 #8
0
        public void RebuildTree(IPanelDebug panelDebug)
        {
            if (!hierarchyHasChanged && m_CurrentPanelDebug == panelDebug)
            {
                return;
            }

            m_CurrentPanelDebug = panelDebug;
            m_Container.Clear();

            int nextId = 1;

            m_TreeRootItems.Clear();

            var visualTree = panelDebug?.visualTree;

            if (visualTree != null)
            {
                var rootItem = new TreeViewItemData <VisualElement>(nextId++, visualTree);
                m_TreeRootItems.Add(rootItem);

                var childItems = new List <TreeViewItemData <VisualElement> >();
                AddTreeItemsForElement(childItems, visualTree, ref nextId);

                rootItem.AddChildren(childItems);
            }

            Func <VisualElement> makeItem = () =>
            {
                var element = new VisualElement();
                element.name = "unity-treeview-item-content";
                element.RegisterCallback <MouseEnterEvent>((e) =>
                {
                    HighlightItemInTargetWindow(e.target as VisualElement);
                });
                element.RegisterCallback <MouseLeaveEvent>((e) =>
                {
                    UnhighlightItemInTargetWindow(e.target as VisualElement);
                });
                return(element);
            };

            // Clear selection which would otherwise persist via view data persistence.
            m_TreeView?.ClearSelection();

            m_TreeView = new TreeView(makeItem, FillItem);
            m_TreeView.SetRootItems(treeRootItems);
            m_TreeView.fixedItemHeight            = 20;
            m_TreeView.style.flexGrow             = 1;
            m_TreeView.horizontalScrollingEnabled = true;
            m_TreeView.onSelectedIndicesChange   += items =>
            {
                if (m_SelectElementCallback == null)
                {
                    return;
                }

                if (!items.Any())
                {
                    m_SelectElementCallback(null);
                    return;
                }

                var index   = items.First();
                var element = m_TreeViewController.GetDataForIndex(index);
                m_SelectElementCallback(element);
            };

            m_TreeViewController = m_TreeView.viewController as DefaultTreeViewController <VisualElement>;
            m_Container.Add(m_TreeView);

            hierarchyHasChanged = false;
            m_SearchBar.ClearSearch();
        }