Hi,
I’m new to Unity and new to JavaScript. But I have an error when I use this code.
It supposed to be playing a little sound when you touch the text with your mouse.
But it gives the following error:
Everything else in the script works perfectly except for the line with audio.Play = sound;
Don’t kill me if its just a simple and noobish mistake.
Here is the script, it is based on an script I found online.
I’ve added it as an attachment for if you wish to use it or edit it.
var isQuit=false;
var sound : AudioClip;
function OnMouseEnter(){
//change text color
renderer.material.color=Color.red;
// Play sound
audio.Play = sound;
}
function OnMouseExit(){
//change text color
renderer.material.color=Color.white;
}
function OnMouseUp(){
//is this quit
if (isQuit==true) {
//quit the game
Application.Quit();
}
else {
//load level
Application.LoadLevel(1);
}
}
function Update(){
//quit game if escape key is pressed
if (Input.GetKey(KeyCode.Escape)) {
Application.Quit();
}
}
Thanks anyway!
1728237–109015–gameMenu.js (532 Bytes)