// -------------------------------------------------------------------------------
    // Name	:	RegisterLayeredAudioSource
    // Desc	:
    // -------------------------------------------------------------------------------
    public ILayeredAudioSource RegisterLayeredAudioSource(AudioSource source, int layers)
    {
        if (source != null && layers > 0)
        {
            // First check it doesn't exist already and if so just return the source
            for (int i = 0; i < _layeredAudio.Count; i++)
            {
                LayeredAudioSource item = _layeredAudio[i];
                if (item != null)
                {
                    if (item.audioSource == source)
                    {
                        return(item);
                    }
                }
            }

            // Create a new layered audio item and add it to the managed list
            LayeredAudioSource newLayeredAudio = new LayeredAudioSource(source, layers);
            _layeredAudio.Add(newLayeredAudio);

            return(newLayeredAudio);
        }

        return(null);
    }
 // -------------------------------------------------------------------------------
 // Name	:	UnregisterLayeredAudioSource (Overload)
 // Desc	:
 // -------------------------------------------------------------------------------
 public void UnregisterLayeredAudioSource(AudioSource source)
 {
     for (int i = 0; i < _layeredAudio.Count; i++)
     {
         LayeredAudioSource item = _layeredAudio[i];
         if (item != null)
         {
             if (item.audioSource == source)
             {
                 _layeredAudio.Remove(item);
                 return;
             }
         }
     }
 }
示例#3
0
    public ILayeredAudioSource RegisterLayeredAudioSource(AudioSource audioSource, int layers)
    {
        if (audioSource != null && layers > 0)
        {
            for (int i = 0; i < _layeredAudio.Count; i++)
            {
                LayeredAudioSource item = _layeredAudio[i];
                if (item != null)
                {
                    if (item.audioSource == audioSource)
                    {
                        return(item);
                    }
                }
            }

            LayeredAudioSource newLayeredAudioSource = new LayeredAudioSource(audioSource, layers);
            _layeredAudio.Add(newLayeredAudioSource);

            return(newLayeredAudioSource);
        }

        return(null);
    }