- Home /
Audio Horizzontal slider problem.
Hi guys, i added at this script the Audio Volume Slider with a GUISlider (is //AudioLevel), but ther's an error: "Insert a semicolon at the end." I don't understand what is wrong! Thank you in advance, paolo
var CurrentSong : AudioClip = null;
var SongList : AudioClip[];
var gSkin : GUISkin;
var SongName : String;
var SongNumber : int = 0;
//AudioLevel
Var sliderstyle2 : GUISkin;
var hSliderValue : float = 0.0;
function Start(){
CurrentSong = SongList[SongNumber];
Music = gameObject.GetComponent(AudioSource);
Music.loop = false;
Music.playOnAwake = true;
Music.clip = CurrentSong;
Music.volume = 2;
audio.Play();
NextSong();
}
function Update () {
SongName = CurrentSong.name;
Music = gameObject.GetComponent(AudioSource);
Music.clip = CurrentSong;
if (SongNumber > SongList.length){
SongNumber = 0;
}
if (SongNumber < 0){
SongNumber = SongList.length;
}
}
function OnGUI(){
//AudioLevel
GUI.skin = sliderstyle2;
if (hSliderValue = GUI.HorizontalSlider (Rect(150, Screen.height-55, 40, 40), "vol")){;
Audio.volume = hSliderValue;
}
GUI.skin = gSkin;
GUI.Box(Rect(10, Screen.height-75, 140, 65), SongName);
if(GUI.Button(Rect(15, Screen.height-55, 40, 40), "<<")){
SongNumber -= 1;
CurrentSong = SongList[SongNumber];
Wait();
}
if(audio.isPlaying){
if(GUI.Button(Rect(60, Screen.height-55, 40, 40), "||")){
audio.Pause();
}
}
if(!audio.isPlaying){
if(GUI.Button(Rect(60, Screen.height-55, 40, 40), ">")){
audio.Play();
}
}
if(GUI.Button(Rect(105, Screen.height-55, 40, 40), ">>")){
SongNumber += 1;
CurrentSong = SongList[SongNumber];
Wait();
}
}
function Wait(){
yield WaitForSeconds(0.05);
audio.Play();
}
function NextSong(){
yield WaitForSeconds (audio.clip.length);
SongNumber += 1;
CurrentSong = SongList[SongNumber];
Wait();
}
Comment
omg that stupid error, there's another now: expecting ), found '='.
Yea, you are trying to an assignment inside your 'if' statement. Pull the assignment out and test 'hSliderValue' inside the 'if' statement.
So? i always error.. :/
//AudioLevel
GUI.skin = sliderstyle2;
if {
(hSliderValue = GUI.HorizontalSlider (Rect(150, Screen.height-55, 40, 40), "vol"))
Audio.volume = hSliderValue;
}
Or so:
if (hSliderValue = GUI.HorizontalSlider) {
(Rect(150, Screen.height-55, 40, 40), "vol"))
Audio.volume = hSliderValue;
}
to test whether two things are equal you need to use == ins$$anonymous$$d of =
Best Answer
Answer by robertbu · Feb 24, 2014 at 05:10 PM
This specific error is caused by you using an upper case 'v' on 'var' on line 9.