Is anyone else using Unity 5 ? I’m having an issue with the SceneManagement, The code and error are below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour {
public float autoLoadNextLevelAfter;
void Start() { if (autoLoadNextLevelAfter > 0) { Invoke("LoadNextLevel", autoLoadNextLevelAfter); } }
public void LoadLevel(string name) { Debug.Log("New Level load: " + name); Scene s = SceneManager.GetSceneByName(name); Debug.Log("Scene is:"); Debug.Log(s.name); Debug.Log(s.buildIndex); SceneManager.LoadScene(s.buildIndex); //Application.LoadLevel(name); }
public void QuitRequest() { Debug.Log("Quit requested"); Application.Quit(); }
public void LoadNextLevel() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); }
}
and the error that I’m getting is below.
Cannot load scene: Invalid scene name (empty string) and invalid build index -1
The name is coming in correctly but when I call GetSceneByName returns null
Thank you in advance!!