void GenerateStabTargets()
{
//set audioSource:
if(tweenArguments.Contains("audiosource")){
audioSource=(AudioSource)tweenArguments["audiosource"];
}else{
if(GetComponent(typeof(AudioSource))){
audioSource=audio;
}else{
//add and populate AudioSource if one doesn't exist:
gameObject.AddComponent(typeof(AudioSource));
audioSource=audio;
audioSource.playOnAwake=false;
}
}
//populate audioSource's clip:
audioSource.clip=(AudioClip)tweenArguments["audioclip"];
//set audio's pitch and volume if requested:
if(tweenArguments.Contains("pitch")){
audioSource.pitch=(float)tweenArguments["pitch"];
}
if(tweenArguments.Contains("volume")){
audioSource.volume=(float)tweenArguments["volume"];
}
//set run time based on length of clip after pitch is augmented
time=audioSource.clip.length/audioSource.pitch;
}