public AiryAudioSource InitAudioSource(AiryAudioData g_data) { AiryAudioSource t_audioSource = null; for (int i = 0; i < myPool.Count; i++) { if (myPool [i].AudioSource.isPlaying == false) { t_audioSource = myPool [i]; } } if (t_audioSource == null) { Debug.Log("Can not find idle audio source!, creating a new one"); t_audioSource = Instantiate(myPool_Prefab, this.transform).GetComponent <AiryAudioSource> (); myPool.Add(t_audioSource); } t_audioSource.SetAudioData(g_data); return(t_audioSource); }
public void SetAudioData(AiryAudioData g_data) { SetAudioClip(g_data.GetMyAudioClip()); if (g_data.isRandomVolume) { SetVolume(Random.Range(g_data.myVolumeRange.x, g_data.myVolumeRange.y)); } else { SetVolume(g_data.myVolume); } if (g_data.isRandomPitch) { SetPitch(Random.Range(g_data.myPitchRange.x, g_data.myPitchRange.y)); } else { SetPitch(g_data.myPitch); } }