- Home /
Question by
loudlazer · Dec 30, 2017 at 03:16 AM ·
scenescene-switchingscene-changescene change
Scenes won't change when built
I am using UnityEditor.SceneManagement to change my scenes, and it works perfectly in editor but they won't change in game. Help please.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor.SceneManagement; public class portal2 : MonoBehaviour {
[SerializeField] private string level;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
EditorSceneManager.LoadScene (level);
}
}
}
Comment
Best Answer
Answer by loudlazer · Dec 30, 2017 at 03:29 AM
Fixed it. I was using UnityEditor.SceneManagement instead of UnityEngine.SceneManagement. Turns out UnityEditor only works in the editor. Also use SceneManager.LoadScene instead of EditorSceneManager.LoadScene.