Using Editor Set Dirty, is not marking the scene as dirty, so no changes are saved

Hi all, I cant figure out why my editor script isnt marking the scene as dirty. If I use it, I have to manually do something else in the level before I save it, and that’s a touch annoying.

Why doesnt my script work the way its intended?

[CustomEditor(typeof(LevelManager))]
public class GenerateID : Editor {

    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        if (GUILayout.Button("Generate ID's"))
        {
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Created Unique GUI");
                GenerateIDs();
            }
        }

        if (GUI.changed)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        DrawDefaultInspector();
    }

    public void GenerateIDs()
    {
        LightManager[] lightscripts = FindObjectsOfType<LightManager>();
        for (int i = 0; i < lightscripts.Length; i++)
        {
            lightscripts*.uniqueID = generateString();*

EditorUtility.SetDirty(lightscripts*);*
}
}
Any help would be greatly appreciated.

In the end, got it working by using the fix in this thread: https://forum.unity3d.com/threads/variables-are-not-saved-with-the-scene-when-using-custom-editor.374984/