void CreateContents() { m_MainToolbarVisual = (MainToolbarVisual)Activator.CreateInstance(EditorUIService.instance.GetDefaultToolbarType()); m_Root?.RemoveFromHierarchy(); m_Root = CreateRoot(); if (windowBackend?.visualTree is VisualElement visualTree) { visualTree.Add(m_Root); m_Root.Add(m_MainToolbarVisual.root); } RepaintToolbar(); }
protected override void OnEnable() { base.OnEnable(); EditorApplication.modifierKeysChanged += Repaint; get = this; m_MainToolbarVisual = (MainToolbarVisual)Activator.CreateInstance(EditorUIService.instance.GetDefaultToolbarType()); m_Root = CreateRoot(); if (windowBackend.visualTree is VisualElement visualTree) { visualTree.Add(m_Root); m_Root.Add(m_MainToolbarVisual.root); } m_EventInterests.wantsLessLayoutEvents = true; RepaintToolbar(); }