Ejemplo n.º 1
0
    public AudioManager.AudioPlayer ObtainPlayer(AudioClip clip)
    {
        if (this.m_sourcePool != null)
        {
            AudioManager.AudioPlayer sourcePool = this.m_sourcePool;
            this.m_sourcePool       = sourcePool.m_nextPlayer;
            sourcePool.m_nextPlayer = null;
            sourcePool.m_info       = null;
            sourcePool.m_source.gameObject.SetActive(true);
            sourcePool.m_source.clip = clip;
            return(sourcePool);
        }
        if (this.m_sourcePoolRoot == null)
        {
            this.m_sourcePoolRoot = AudioManager.GetSourcePoolRoot();
        }
        GameObject gameObject = new GameObject("Audio Source");

        gameObject.transform.parent = this.m_sourcePoolRoot;
        return(new AudioManager.AudioPlayer {
            m_source = gameObject.AddComponent <AudioSource>(),
            m_transform = gameObject.transform,
            m_info = null,
            m_source =
            {
                playOnAwake = false,
                clip        = clip
            }
        });
    }
Ejemplo n.º 2
0
 public void ReleasePlayer(AudioManager.AudioPlayer player)
 {
     if (player.m_source != null)
     {
         player.m_source.Stop();
         player.m_source.clip = null;
         player.m_source.gameObject.SetActive(false);
     }
     if (player.m_info != null)
     {
         player.m_info.ReleaseClip();
         player.m_info = null;
     }
     player.m_nextPlayer = this.m_sourcePool;
     this.m_sourcePool   = player;
 }