I have a collider in my level, and when you touch it, it loads an assigned scene. The scene is assigned in the inspector by dragging the scene onto the public object variable. When I build the game, this variable that I had set in the inspector was said to be null (I did a dev build to figure that out).
My exit script is nothing special, but here it is:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ExitScript : MonoBehaviour {
public Object nextScene;
public string nextLevel;
public LevelManager levelManager;
void Start()
{
nextLevel = nextScene.name;
levelManager = FindObjectOfType<LevelManager> ();
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player") {
levelManager.changingLevel = true;
levelManager.ChangeLevel (nextLevel);
}
}
}