Home > Software engineering >  why am I losing all gameObjects in unity when I have more then one scene
why am I losing all gameObjects in unity when I have more then one scene

Time:05-28

I am trying to create a tower defense game and I made a menu scene and a level01 scene. Now when I create some objects in the menu scene, and go to the level01 scene, I lose all my objects in my menu scene. I don't know what is going on. I have tried to create a new menu scene and duplicating my level01 scene, but it doesn't work.

CodePudding user response:

You can use DontDestroyOnLoad or you can add multiple scenes and never unload the menu scene.

SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);

CodePudding user response:

The use of a scene, as its name implies, is to prescribe a different scene and arrangement. If you can design the gameplay inside a scene and deactivate them beforehand instead of adding objects. This will make the code more consistent and will prevent future problems.

  • Related