Spawning game objects in edit mode vanish after switching scenes

Hello,

So I’ve trying to spawn game objects while in edit mode, which I have worked just fine however soon as I switch scene (never enter play mode) and then switch back, all the objects I just created vanish.

I have [ExecuteInEditMode] at the top, here is my spawning code:

private void AddWaveSystem()
    {
        if (GameObject.FindObjectOfType<WaveManager>())
        {
            Debug.Log("WaveManager Already Exists!");
            return;
        }

        GameObject go = new GameObject("WaveManager");
        go.AddComponent<WaveManager>();

    }

This spawns the object just fine, but it’s not saving. Any help is great, Thanks!

after some research into editor tools, I managed to fix the issue by using ObjectFactory, thanks for the help. code:

private void AddWaveSystem()
    {
        if (GameObject.FindObjectOfType<WaveManager>())
        {
            Debug.Log("WaveManager Already Exists!");
            return;
        }

        ObjectFactory.CreateGameObject("WaveManager", typeof(WaveManager));

    }