In the Build Settings I have two scenes at index 0 and index 1:

Build Settings

Then in the Hierarchy I have the two scenes: The active scene is the MainMenu:


In the StartGameButton I added to it a script component. In the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadSceneOnClick : MonoBehaviour
  public void LoadByIndex(int sceneIndex)

And this is the StartGameButton Inspector:


I dragged the script on the OnClick I selected the function LoadSceneOnClick And set the index to 1

When the game start and I click on the button it stay on the Main Menu scene and not loading anything.

The problem I guess is that I'm getting error in the game No cameras rendering:

Game View

The problem is that when I'm running the game and it start from the main menu scene in the space station scene I'm enable false the Player and the Player is a first person character with a camera:


You can see in the Inspector that the Player is unchecked the Player is not enabled. If I will enable the Player and even if the main menu scene is the active one it will show me the player and the player camera and not the main menu. So I had to turn off the Player.

The question now is where by script do I enable back the Player when it's loading the scene ?

Inside the LoadSceneOnClick script ?


1 Answer 1


It's a matter of preference and experience.

I would create some kind of ScriptableObject with events and data required after the new scene was loaded. Then I would have some kind of controller with event on scene loaded and pass the data there from assets. Then from it I would execute all required actions via method in that ScriptableObject. But that might look too complicated.

What I suggest that for main menu visuals, you create a separate scene that loads additively and that doesn't have all of these game-play related features. It only has what is required for the main menu. Ideally you would put all of these into Main Menu scene.

But for your case the best would be to not load the new scene, but to enable the Player and unload the Main Menu scene. This way you don't have to load the same scene again and you have your game-play ready state.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .