public virtual void OnCreate(IWindowModel model) { m_Model = model; m_Panel = EditorPanel.FindOrCreate(model as ScriptableObject); m_Panel.visualTree.SetSize(m_Model.size); m_Panel.IMGUIEventInterests = m_Model.eventInterests; imguiContainer = new IMGUIContainer(m_Model.onGUIHandler) { useOwnerObjectGUIState = true }; imguiContainer.StretchToParentSize(); imguiContainer.viewDataKey = "Dockarea"; imguiContainer.name = VisualElementUtils.GetUniqueName("Dockarea"); imguiContainer.tabIndex = -1; imguiContainer.focusOnlyIfHasFocusableControls = false; m_Panel.visualTree.Insert(0, imguiContainer); Assert.IsNull(m_Panel.rootIMGUIContainer); m_Panel.rootIMGUIContainer = imguiContainer; m_Model.sizeChanged = OnSizeChanged; m_Model.eventInterestsChanged = OnEventsInterestsChanged; }
private bool UpdatePreviewTexture(int width, int height) { var vta = target as VisualTreeAsset; bool dirty = false; int currentDirtyCount = EditorUtility.GetDirtyCount(target); if (vta != m_LastTree || !m_LastTree || currentDirtyCount != m_LastDirtyCount || vta.contentHash != m_LastContentHash) { m_LastTree = vta; m_Tree = vta.Instantiate(); m_Tree.StretchToParentSize(); m_LastDirtyCount = currentDirtyCount; m_LastContentHash = vta.contentHash; dirty = true; } if (m_Panel == null) { m_Panel = EditorPanel.FindOrCreate(m_LastTree); var visualTree = m_Panel.visualTree; UIElementsEditorUtility.AddDefaultEditorStyleSheets(visualTree); dirty = true; } if (dirty) { m_Panel.visualTree.Clear(); m_Panel.visualTree.Add(m_Tree); RenderStaticPreview(width, height, ref m_preview_texture); } return(dirty); }