0
\$\begingroup\$

The problem is that if I turn the camera on enabled in the editor it will show part of the scene mixed with the main menu scene. And if the loading scene main camera is enabled off I will get error Display 1 No cameras rendering.

I have two scenes in the Hierarchy. The first is Main Menu. The main menu have a camera.

Scene main menu

Now I did that when I click on the button START A NEW GAME It will load another scene:

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

public class NewGame : MonoBehaviour
{
    public void StartNewGame(int SceneIndex)
    {
        SceneManager.LoadScene(SceneIndex);
    }
}

In this screenshot you can see in the Inspector I'm calling the method StartNewGame and the index 1. Index 1 present the second scene that should be load: The Space Station

Scene

Now in the scene: The Space Station I have also a MainCamera under Player. The MainCamera is turned off in the editor. And I need somehow to switch between the Main Menu scene camera and the The Space Station scene camera.

Scene

If I will turn on the MainCamera in the inspector I will see some objects of the first scene and the second scene and then the game will start without the main menu and the player will fall down.

If I start the game when the MainCamera is turned off I will the Main Menu but then when I click on START A NEW GAME it will show me the message Display 1 No cameras rendering.

The last screenshot is of the Build Settings: Edit > Build Settings... I added the two scenes to the build. The first scene at index 0 is the Main Menu the second scene at index 1 is The Space Station:

Build Settings

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Your StartNewGame() function does load a new scene, but you haven't specified what mode you want it to load in.

You should change your line of code from

SceneManager.LoadScene(SceneIndex);

To:

SceneManager.LoadScene(SceneIndex, LoadSceneMode.Single);

This specifies what kind of mode you want to load your scene in.

Edit: Because of this you should also enable you camera in the SpaceStation scene again

\$\endgroup\$
2
  • \$\begingroup\$ My whole project deleted destroyed by mistake and I didn't back it up. So now I'm close to re build it again. So I didn't have the time yet to test the scenes part. My whole main menu is gone. I hope tonight(my local time) or tomorrow to finish and test it. Sorry. \$\endgroup\$
    – Daniel Lip
    Commented Mar 5, 2018 at 18:48
  • \$\begingroup\$ That's alright. Good luck!:) \$\endgroup\$
    – sebastian
    Commented Mar 6, 2018 at 11:22

You must log in to answer this question.

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