madsbangh / EasyButtons

Add buttons to your inspector in Unity super easily with this simple attribute
MIT License
1.08k stars 83 forks source link

Use UI Toolkit rendering instead of old IMGUI - Code provided #25

Open leorid opened 1 year ago

leorid commented 1 year ago

In "ObjectEditor.cs" just replace

public override void OnInspectorGUI() { DrawDefaultInspector(); _buttonsDrawer.DrawButtons(targets); }

with

public override VisualElement CreateInspectorGUI()
{
    VisualElement container = new VisualElement();

    InspectorElement.FillDefaultInspector(container, serializedObject, this);

    IMGUIContainer iMGUIContainer = new IMGUIContainer(() =>
    {
        _buttonsDrawer.DrawButtons(targets);
    });
    container.Add(iMGUIContainer);

    return container;
}

It's just more performant in the Editor.