Question by
MrBellrick · Jun 26, 2020 at 10:11 PM ·
script.sceneload
I am new to unity and I am having problems with my code when trying to load the current scene
using UnityEngine;
public class GameManager : MonoBehaviour {
bool gameHasEnded = false;
public void EndGame() {
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log("Game Over");
Restart();
}
}
void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
I get these erroer:
Assets\Scripts\GameManager.cs(23,32): error CS0103: The name 'SceneManager' does not exist in the current context
Assets\Scripts\GameManager.cs(23,9): error CS0103: The name 'SceneManager' does not exist in the current context
Eny sugjestions on how to fix it?
Comment
Best Answer
Answer by markythemurloc · Jun 26, 2020 at 10:34 PM
Hey!
You need to be using UnityEngine.SceneManagement in your script in order to preform this action. using UnityEngine.SceneManagement; - Place this under your 'using UnityEngine' line and you should be good.