New with UIElements in 2019 - How to draw default inspector

As title, I use Unity 2019.1 and try new UIElements. This feature can load UI from uxml. But how to draw default inspector? I tried DrawDefaultInspector() but it didn’t work.

public override VisualElement CreateInspectorGUI()
    {
        DrawDefaultInspector();
        var root = new VisualElement();

        var uxml = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Editor/Test.uxml");
        var uss = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Editor/Test.uss");

        uxml.CloneTree(root);
        root.styleSheets.Add(uss);

        return root;
    }

I know you have probably found a solution to this already but I’m going to post this here for the other people who didn’t.
You just have to add this ‘defaultInspector’ VisualElement to the root.

IMGUIContainer defaultInspector = new IMGUIContainer(() => DrawDefaultInspector());
7 Likes