示例#1
0
        public void Render(VisualTreeAsset vta, Rect r, GUIStyle background)
        {
            if (Event.current.type != EventType.Repaint || r.width < 100 && r.height < 100)
            {
                return;
            }

            bool dirty = false;

            if (vta != m_LastTree || !m_LastTree)
            {
                m_LastTree = vta;
                m_Tree     = vta.CloneTree(null);
                m_Tree.StretchToParentSize();
                dirty = true;
            }

            if (m_Panel == null)
            {
                UXMLEditorFactories.RegisterAll();
                m_Panel = UIElementsUtility.FindOrCreatePanel(m_LastTree, ContextType.Editor, new DataWatchService());
                if (m_Panel.visualTree.styleSheets == null)
                {
                    UIElementsEditorUtility.AddDefaultEditorStyleSheets(m_Panel.visualTree);
                    m_Panel.visualTree.LoadStyleSheetsFromPaths();
                }
                m_Panel.allowPixelCaching = false;
                dirty = true;
            }

            if (dirty)
            {
                m_Panel.visualTree.Clear();
                m_Panel.visualTree.Add(m_Tree);
            }

            EditorGUI.DrawRect(r, EditorGUIUtility.isProSkin ? EditorGUIUtility.kDarkViewBackground : HostView.kViewColor);

            m_Panel.visualTree.layout = GUIClip.UnclipToWindow(r);

            m_Panel.visualTree.Dirty(ChangeType.Layout);
            m_Panel.visualTree.Dirty(ChangeType.Repaint);

            var oldState = SavedGUIState.Create();
            int clips    = GUIClip.Internal_GetCount();

            while (clips > 0)
            {
                GUIClip.Pop();
                clips--;
            }

            m_Panel.Repaint(Event.current);

            oldState.ApplyAndForget();
        }
示例#2
0
 public void Render(VisualTreeAsset vta, Rect r, GUIStyle background)
 {
     if (Event.current.type == EventType.Repaint && (r.width >= 100f || r.height >= 100f))
     {
         bool flag = false;
         if (vta != this.m_LastTree || !this.m_LastTree)
         {
             this.m_LastTree = vta;
             this.m_Tree     = vta.CloneTree(null);
             this.m_Tree.StretchToParentSize();
             flag = true;
         }
         if (this.m_Panel == null)
         {
             UXMLEditorFactories.RegisterAll();
             this.m_Panel = UIElementsUtility.FindOrCreatePanel(this.m_LastTree, ContextType.Editor, new DataWatchService());
             if (this.m_Panel.visualTree.styleSheets == null)
             {
                 UIElementsEditorUtility.AddDefaultEditorStyleSheets(this.m_Panel.visualTree);
                 this.m_Panel.visualTree.LoadStyleSheetsFromPaths();
             }
             this.m_Panel.allowPixelCaching = false;
             flag = true;
         }
         if (flag)
         {
             this.m_Panel.visualTree.Clear();
             this.m_Panel.visualTree.Add(this.m_Tree);
         }
         EditorGUI.DrawRect(r, (!EditorGUIUtility.isProSkin) ? HostView.kViewColor : EditorGUIUtility.kDarkViewBackground);
         this.m_Panel.visualTree.layout = GUIClip.UnclipToWindow(r);
         this.m_Panel.visualTree.Dirty(ChangeType.Layout);
         this.m_Panel.visualTree.Dirty(ChangeType.Repaint);
         SavedGUIState savedGUIState = SavedGUIState.Create();
         for (int i = GUIClip.Internal_GetCount(); i > 0; i--)
         {
             GUIClip.Pop();
         }
         this.m_Panel.Repaint(Event.current);
         savedGUIState.ApplyAndForget();
     }
 }