In your Unity project look for the “Editor” folder. Create it if it does not exist.

Create a new C# script:

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(YourComponent))]  // Replace YourComponent with the name of your component
public class YourComponentEditor : Editor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        YourComponent component = (YourComponent)target;

        if (GUILayout.Button("Your Button"))
        {
            // Perform button action here
            component.YourButtonClicked();
        }
    }
}

Replace YourComponent with the name of your component

Next time you see your components details in the Unitys Inspector, you will a Button. Excelent for testing