/// <summary> /// Send an audio source back to the stack /// </summary> /// <param name="source">The audio source to collect</param> public void Collect(SAudioSource source) { int index; if(indexLookup.TryGetValue(source.GetInstanceID(), out index)) { pool[index].gameObject.transform.SetParent(poolParent.transform); pool[index].gameObject.SetActive(false); freeStack.Push(index); } }
private void AudioCallback(SAudioSource source) { Queue<string> audioQueue; if(audioQueues.TryGetValue(source.id, out audioQueue)) { if(audioQueue.Count > 0 && !source.isStopped) { AudioManager.InternalPlay(source.id, audioQueue.Dequeue()); } else { audioQueues.Remove(source.id); } } channelManager.CompletePlay(source); }
public void CompletePlay(SAudioSource source) { Remove(source, source.channelKey); audioSourcePool.Collect(source); }
private void Remove(SAudioSource source, string channelKey) { if(audioChannels.ContainsKey(source.channelKey)) { List<SAudioSource> channel; audioChannels.TryGetValue(source.channelKey, out channel); channel.Remove(source); if(channel.Count == 0) { audioChannels.Remove(source.channelKey); UpdateChannelAudio(); } } }
private void Add(SAudioSource source, string channelKey) { if(audioChannels.ContainsKey(channelKey)) { List<SAudioSource> channel; audioChannels.TryGetValue(channelKey, out channel); channel.Add(source); } else { List<SAudioSource> channel = new List<SAudioSource>(); channel.Add(source); audioChannels.Add(channelKey, channel); UpdateChannelAudio(); } }