将多个音频组合起来进行播放
代码如下:
//频率
public int Hz = 16000; [SerializeField] AudioClip s1; [SerializeField] AudioClip s2; [SerializeField] AudioClip s3; AudioSource source; AudioClip clip; // Use this for initialization void Start () { float[] data1 = new float[s1.samples * s1.channels]; float[] data2 = new float[s2.samples * s2.channels]; float[] data3 = new float[s3.samples * s3.channels]; s1.GetData (data1, 0); s2.GetData (data2, 0); s3.GetData (data3, 0); List<float> ar = new List<float> (); ar.AddRange (data1); ar.AddRange (data2); ar.AddRange (data3); float[] datas = ar.ToArray (); clip = AudioClip.Create ("temp", datas.Length, 1, Hz, false); clip.SetData (datas, 0); source = this.GetComponent<AudioSource> (); source.clip = clip; source.Play (); }