Display uxml inspector in EditorWindows

Hello,
I created a custom editor with uxml and uss, which works perfectly fine, but now, I am trying to display it within an EditorWindow. However I can only display the default inspector (commented code) using OnInspectorGUI.
Any help is appreciated, thanks a lot.

using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

public class EditorTest : EditorWindow {
    private static int _armor  = 75;
    private static int _damage = 25;

    [MenuItem("EditorTest/Open _%#T")]
    public static void ShowWindow() {
        // Opens the window, otherwise focuses it if it’s already open.
        var window = GetWindow<EditorTest>();

        // Adds a title to the window.
        window.titleContent = new GUIContent("EditorTest");

        // Sets a minimum size to the window.
        window.minSize = new Vector2(250, 50);
    }

    /*
    private void OnGUI() {
        var editor = Editor.CreateEditor(TestEditorWindow.Instance);
        editor.OnInspectorGUI();
    }*/

   private void OnEnable() {
       var editor = Editor.CreateEditor(TestEditorWindow.Instance);
       editor.CreateInspectorGUI();
   }
}

public class TestEditorWindow : System.ScriptableSingleton<TestEditorWindow> {
    public int armor  = 75;
    public int damage = 25;
    public string text;
}

[CustomEditor(typeof(TestEditorWindow))]
public class TestEditorWindowEditor : Editor {
   
    public override VisualElement CreateInspectorGUI() {
        VisualElement customInspector = new VisualElement();
        var quickToolVisualTree = Resources.Load<VisualTreeAsset>("EditorTest_Main");
        quickToolVisualTree.CloneTree(customInspector);
        customInspector.styleSheets.Add(Resources.Load("custom-editor-uie-style") as StyleSheet);
        return customInspector;
    }
}

Bump, I am also facing this problem :frowning:

I’ve been facing a similar issue, I hope that helps ! :wink:

(basically, the inability of CreateEditor to use UI elements)

5796721--612433--Unity_2020-05-03_05-07-04.png

5796721--612439--devenv_2020-05-03_05-09-12.png

In short, re-use your elements tree where you need it + Bind().

:slight_smile: