- Home /
Question by
M-BOMB · Mar 19, 2014 at 02:53 PM ·
onguicompiler-error
Compiling error: [0x00000] in :0
I made my first game in unity using C#, game works perfect in Unity, but when I make "Build & Run" the game dosn't work. I check the "output_log.txt" and says this:
NullReferenceException: Object reference not set to an instance of an object at scr_menu.OnGUI () [0x00000] in :0
(Filename: Line: -1)
I don't know what are I'm doing wrong, please help.
This is the script: using UnityEngine; using System.Collections;
public class scr_menu : MonoBehaviour {
public AudioClip select;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
if (GUI.Button (new Rect (Screen.width/2 - 75,Screen.height/2 + 35,150,50),"Play Game")) {
audio.PlayOneShot (select);
Application.LoadLevel ("level_selector");
}
if (GUI.Button (new Rect (Screen.width/2 - 75,Screen.height/2 + 90,150,50),"Options")) {
audio.PlayOneShot (select);
Application.LoadLevel ("options");
}
if (GUI.Button (new Rect (Screen.width/2 - 75,Screen.height/2 + 145,150,50),"Exit Game")) {
audio.PlayOneShot (select);
StartCoroutine (exiting());
}
}
IEnumerator exiting () {
yield return new WaitForSeconds(2);
Application.Quit();
}
}
I made the project in Unity 4.3.4f1
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Gui placement help 1 Answer
Yield function goes slow sometimes/differently? 2 Answers
How can i fix this error? 2 Answers
OnCollisionEnter called twice 2 Answers