[Solved]I can't seem to get my next screen to appear

I have either missed something or have it all confused. I am using 5.3 ( I know, I know) and have incorporated the UnityEngine.SceneManagement and the following occurs. I am able to call on the LevelManager class and get loadScene to work. I see it in the Console messages but the scene does not change. I will paste the images and my code below. Some help would be appreciated.
height=“186”>
Since I can only put in one image you’ll have to take my word for it that I spelled it correctly. I actually have spelled it different ways to see if that was the problem.
here is my script…

`using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LevelManager : MonoBehaviour {

public float autoLoadNextLevelAfter;

void Start(){
	if (autoLoadNextLevelAfter == 0) {
		Debug.Log ("Level auto load disabled.");
	} else {
		Invoke ("LoadNextLevel", autoLoadNextLevelAfter);
	}
}
public void LoadScene(string name) {
	Debug.Log("New Level load: " + name);
	int thisLevel = SceneManager.GetActiveScene().buildIndex; 
}
public void QuitRequest() { 
	Debug.Log("Quit requested");
	Application.Quit();
}

public void LoadNextLevel(){
	Debug.Log ("auto loaded " + name);
	SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

}

}
Any help at all would be appreciated.`

OnClick you’re calling your LoadScene method, but it doesn’t actually load a scene after the debug statement. It initialises int thisLevel to the value of SceneManager.GetActiveScene().buildIndex but it doesn’t do anything with it (and it’s redundant anyway), or with the scene name which is passed into the method in the editor.

You need to call SceneManager.LoadScene(name) in the LoadScene method.

I’m surprised it compiles at all because the LoadNextLevel() method references name which isn’t visible to that method.

Does that help?

1 Like

I’ll try that shortly. I thought I had already replaced this - int thisLevel = SceneManager.GetActiveScene().buildIndex; withSceneManager.LoadScene(name) already. But maybe not. I’ll have another look. It’s my fault for being in 5.3 before I needed to but I have also noticed that when we get to the sections that use it we don’t use SceneManagement in the scripts any longer. Maybe I missed it but I looked at the relevant scripts and never saw it listed.

That was the trick. Damn I need to really get on the mark with SceneManagement. I have a hard time with it for sure. Thank You.

1 Like

Privacy & Terms