- Home /
Error: Reference on this Behavior is Missing.
public class Menu : MonoBehaviour { public bool QuitButton = false; public AudioClip Click; public Texture2D normalTexture; public Texture2D rollOverTexture; public int levelToLoad;
void OnMouseEnter()
{
guiTexture.texture = rollOverTexture;
}
void OnMouseExit()
{
guiTexture.texture = normalTexture;
}
void OnMouseDown()
{
audio.PlayOneShot(Click);
if (QuitButton)
{
Application.Quit();
}
else
{
Application.LoadLevel (levelToLoad);
}
}
}
This is my simple menu script. It works inside the Editor during testing purposes but after I do a build it never works. I believe it is because I get a "Reference on this Behavior is Missing" Error. Any clues on why?
It really depends on the context I guess. I can't see any obvious errors in the code you the missing behavior sounds familiar. That's when a game object might have lost one or more of its scripts (due to file renames etc). However, since you say it works in the editor, that kind of rules out that possibility (with working, I assume you don't get that error message at all and found that message in the built executables output log). Are you sure you don't have a prefab hanging around somewhere with a missing script? What makes you suspect that code? What line report errors?
Answer by doomprodigy · Dec 19, 2010 at 04:42 AM
Fixed it, I forgot to add my audio to script, so It then decided that without the Audio the build would not work. Cheers for explaining Statement.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091606im_/https://answers.unity.com/themes/thub/images/avi.jpg)