How can i make a text changed event in EditorGUILayout.TextField ?

void OnGUI()
{
GUILayout.Label(“Base Settings”, EditorStyles.boldLabel);
objectsName = EditorGUILayout.TextField(“By Name”, objectsName);

        groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
        myBool = EditorGUILayout.Toggle("Toggle", myBool);
        myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
        EditorGUILayout.EndToggleGroup();

        GUILayout.FlexibleSpace();
        
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUI.enabled = false;
        if (GUI.changed)
        {
            GUI.enabled = true;
        }
        if (GUILayout.Button("Name"))
        {
            
        }
        EditorGUILayout.EndHorizontal();
    }

I want to make that if i type something inside the EditorGUILayout.TextField it will enable the button and if it’s empty then disable again the button.

I tried this part:

GUI.enabled = false;
            if (GUI.changed)
            {
                GUI.enabled = true;
            }

It’s changing it to false the button but never change it back to true.
I want when i type anything in the EditorGUILayout.TextField it will enable true the button the “Name” and if i will delete the text from the EditorGUILayout.TextField it will enable false the button again.

Try this:

    string objectsName = "";
    void OnGUI()
         {
             GUILayout.Label("Base Settings", EditorStyles.boldLabel);
             objectsName = EditorGUILayout.TextField("By Name", objectsName);
     
             groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
             myBool = EditorGUILayout.Toggle("Toggle", myBool);
             myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
             EditorGUILayout.EndToggleGroup();
     
             GUILayout.FlexibleSpace();
             
             EditorGUILayout.BeginHorizontal();
             GUILayout.FlexibleSpace();
             EditorGUI.BeginDisabledGroup (objectsName == "");
             if (GUILayout.Button("Name"))
             {
                 
             }
             EditorGUILayout.EndHorizontal();
             EditorGUI.EndDisabledGroup ();
         }