void Update()
{
for (int i = 0; i < toFreeList.Count; ++i)
{
AudioChannel channel = toFreeList[i];
// 回收AudioClip
Dictionary <string, AudioCache> .Enumerator er = ClipCacheDic.GetEnumerator();
while (er.MoveNext())
{
if (er.Current.Key.Equals(channel.Name))
{
AudioCache cache = er.Current.Value;
cache.AddClip(channel.Clip);
channel.Reset();
}
}
// 回收AudioChannel
freeList.Add(channel);
useList.Remove(channel);
if (useList.Count + freeList.Count > _maxChannel && freeList.Count > 0)
{
GameObject obj = freeList[0].gameObject;
freeList.RemoveAt(0);
GameObject.Destroy(obj);
}
}
toFreeList.Clear();
}