- Home /
Question by
chaguaramo · Apr 04, 2014 at 01:51 AM ·
audioaudiosourcefadefadein
How to fade in-out groups of audio sources?
Hi, I have this script for play groups of audio sources when the gameObject "audio zone" is triggered. Can somebody help me for start this group of audio clips with a fade in and stop them with a fade out when the gameObject object "audio zone" is triggered?
#pragma strict
var audioSources;
function Start(){
audioSources = gameObject.GetComponentsInChildren(AudioSource);
}
function OnTriggerExit(){
Debug.Log("stopping sounds");
Debug.Log(this);
var self = this;
for (var source:AudioSource in audioSources) {
Debug.Log(source);
source.Stop();
}
}
function OnTriggerEnter(){
Debug.Log("starting sounds");
Debug.Log(this);
var self = this;
for (var source:AudioSource in audioSources) {
Debug.Log(source);
source.Play();
}
}
Comment