Hi everyone ;
i want to play backround music in gameplay .For example ;
Sounds
Sounds1
Sounds2
Sounds1 start to play after finishing Sounds. And the looping them. How can i solve this problem?
Any help i will be apriciate.
Hi everyone ;
i want to play backround music in gameplay .For example ;
Sounds
Sounds1
Sounds2
Sounds1 start to play after finishing Sounds. And the looping them. How can i solve this problem?
Any help i will be apriciate.
It actually is a very simple script…
Attach this script to your camera… it will make an audiosource for you if it is not on there. Fill the sound track with music, set the volume. play away.
var soundTrackVolume=0.5;
var soundTrack:AudioClip[];
private var currentTrack=-1;
function Start(){
if(!audio){
gameObject.AddComponent(AudioSource);
}
audio.dopplerLevel=0.0;
audio.volume=soundTrackVolume;
audio.loop=false;
audio.playOnAwake=true;
}
function Update(){
if(soundTrack.length==0)
return;
if(!audio.isPlaying){
currentTrack=(currentTrack + 1) % soundTrack.length;
audio.clip=soundTrack[currentTrack];
print("Now playing: " + soundTrack[currentTrack].name);
}
}
Thank you Big Mister
Here is the Code:
var soundTrackVolume=0.5;
var soundTrack:AudioClip[];
private var currentTrack=-1;
function Start(){
if(!audio){
gameObject.AddComponent(AudioSource);
}
audio.dopplerLevel=0.0;
audio.volume=soundTrackVolume;
audio.loop=false;
audio.playOnAwake=true;
}
function Update(){
if(soundTrack.length==0)
return;
if(!audio.isPlaying){
currentTrack=(currentTrack + 1) % soundTrack.length;
audio.clip=soundTrack[currentTrack];
audio.Play(); [COLOR="red"]// Play The sound[/COLOR]
print("Now playing: " + soundTrack[currentTrack].name);
}
}