3
votes

I'm using Unity 5.6.0f3 and have come across this error when I try build and run. Ive checked in monodeveloper building and running script and it says build success. when I try for windows/mac/Linux standlone I get the below error messages.

Assets/Scripts/LevelManager.cs(4,19): error CS0234: The type or namespace name SceneManagement' does not exist in the namespaceUnityEngine'. Are you missing an assembly reference?

Assets/Scripts/LevelManager.cs(6,29): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?

Error building Player because scripts had compiler errors

.cs is as follows

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LevelManager : MonoBehaviour {
    public void Loadevel(string name) {
        Debug.Log("Level load requested for: " + name);
        SceneManager.LoadScene(name);
        Debug.Log("Loaded Level " + name);
    }

    public void QuitLevel(string name) {
        Debug.Log("I want to Quit");
        Application.Quit();
    }
}

Im cant seem to find any answer on the net and am unable to figure it out at present.

1
Most of the internet seems to suggest that this error appears when you're using a version below 5.3, are you sure you're on 5.6? Also, is the application able to run in the editor? - Iggy
I just tried this myself on 5.6.0f3 and could not replicate. - Draco18s no longer trusts SE
I updated unity to 5.6.0f3 before starting. It runs in editor fine just doesnt build. Maybe ill delete it and start again! Did you use monodevelop Draco18s to write .cs? Ill try again in tomorrow and see. - Fil
Try re-importing assets, this will regenerate the CSharp project and might fix this error. - Kroltan

1 Answers

1
votes

I had similar problem.

Reimporting assests didn't help, as restarting the computer, reinstaling the same version of unity and reinstalling visual studio.

Finnaly I got it to work by updating to unity beta.