For examle I take my project ui extensions.
I needed to add a variable to contentSizeFitter.
This code I'll use for ContentSizeFitter
[RequireComponent(typeof(LayoutGroup))]
public class Zdy_ContentSizeFitter : ContentSizeFitter
{
private LayoutGroup layoutGroup;
[SerializeField] private ContentSize_Element contentSizeElement;
protected override void Start()
{
base.Start();
layoutGroup = GetComponent<LayoutGroup>();
}
...
}
We will add this variable in inspector
private ContentSize_Element contentSizeElement;
- Create folder named "Editor anywhere like this:

- Create Extension Editor Script in this folder like this:

- Сreate a script that includes these methods:
public override void OnInspectorGUI()
protected override void OnEnable()
protected virtual void DrawConfigInfo()
- Do like me) :
[CustomEditor(typeof(Zdy_ContentSizeFitter))]
public class Zdy_ContentSizeFitterEditor : ContentSizeFitterEditor
{
private SerializedProperty contentSizeElement;
public override void OnInspectorGUI()
{
this.serializedObject.Update();
this.DrawConfigInfo();
this.serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI();
}
protected override void OnEnable()
{
base.OnEnable();
this.contentSizeElement = this.serializedObject.FindProperty("contentSizeElement");
}
protected virtual void DrawConfigInfo()
{
EditorGUILayout.PropertyField(this.contentSizeElement);
}
}
And now we can see this variable in inspector:

"ContentSizeFitterEditor" we take from UnityEditor.UI;
In your case we should inherit from "ButtonEditor"
Like this:
using UnityEditor;
using UnityEditor.UI;
public class Zdy_ContentSizeFitterEditor : ButtonEditor
For an in-depth study of this issue, it is better to follow the link in the previous answer))
And you can check out this link here is an example with a button