3

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.

4
  • 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? Commented Apr 18, 2017 at 18:47
  • I just tried this myself on 5.6.0f3 and could not replicate. Commented Apr 18, 2017 at 20:58
  • 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. Commented Apr 18, 2017 at 21:08
  • Try re-importing assets, this will regenerate the CSharp project and might fix this error. Commented Apr 29, 2017 at 13:31

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.