Assets/Scripts/GlobalHealth.cs(4,19): error CS0234: The type or namespace name SceneManagement' does not exist in the namespace UnityEngine’. Are you missing an assembly reference?
I can’t seem to fix it! Please help!
Many thanks in advance.
This is the script (it’s purpose is to manage a player’s health):
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GlobalHealth : MonoBehaviour {
public static int PlayerHealth = 10;
public int InternalHealth;
public GameObject HealthDisplay;
void Update () {
InternalHealth = PlayerHealth;
HealthDisplay.GetComponent<Text> ().text = "Health: " + PlayerHealth;
if (PlayerHealth == 0) {
SceneManager.LoadScene (1);
}
}
}
You should probably upgrade your Unity!
If there’s a way to find which version introduced this class, I’m not aware of it. (Like Microsoft docs do with C#)
That’s an older version, though, so my best guess is that it was not available back then, which @Brathnann was probably curious about.
SceneManager was added in 5.3. There are other threads about it. Upgrade to at least 5.3.x and add the import, then things should work normally. I’d get a 2017 version though.
Looks like everyone beat me to it. But yeah, that was the point I was aiming for.
The older version of Unity used Application.LoadScene, but as mentioned, considering how old 5.1 is, it certainly couldn’t hurt to upgrade your version of Unity.
If you are almost done, it might make sense to stay where you are and just use the old docs. Version upgrades can get messy. Especially jumping a several years in one go.