Error only appears when it builds
I'm building a game now, and its running fine but when I try to build it I get this error:
Assets/Scripts/ReSet.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?
This is the script that it's referencing:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.SceneManagement;
using UnityEngine.UI;
public class ReSet : MonoBehaviour {
private float timer;
public string levelSelect;
public float timeTo;
void Update(){
timer += Time.deltaTime;
if (timer > timeTo) {
EditorSceneManager.LoadScene (levelSelect);
}
}
}
Thank you so much if you can help.
Answer by Matthewj866 · Apr 26, 2017 at 02:59 AM
Hi there.
The issue is straightforward - The unity editor does not get built into projects, thus UnityEditor
will never exist in a build.
What you want is UnityEngine.SceneManagement.SceneManager
rather than UnityEditor.SceneManagement.EditorSceneManager
.
Just change your using
statement over from UnityEditor.SceneManagement
to UnityEngine.SceneManagement
and change EditorSceneManager.LoadScene
to SceneManager.LoadScene
.
Hope this helps.
.
Your answer
Follow this Question
Related Questions
No errors in editor but "buildslave" errors when game is built 0 Answers
Hello, I need some help to fix this error 0 Answers
Error while trying to build XCode project 0 Answers
IL2CPP Windows Build 0 Answers