Ejemplo n.º 1
0
    public SoundFX Add(string strResID, bool IsLoop, Transform tmParent, float fDelay, float volumn = 1f)
    {
        // 추가
        List <SoundFX> listSound = null;

        if (false == m_hashList.TryGetValue(strResID, out listSound))
        {
            listSound = new List <SoundFX>();
            m_hashList.Add(strResID, listSound);
        }

        for (int i = listSound.Count; i > 0;)
        {
            SoundFX sound = listSound[--i];
            if (null == sound)
            {
                listSound.RemoveAt(i);
            }
            else
            {
                if (false == sound.gameObject.activeSelf)
                {
                    sound.gameObject.SetActive(true);
                    return(sound);
                }
            }
        }

        SoundFX soundCreate = SoundFX.Create(Resources.Load(strResID) as AudioClip, IsLoop, tmParent, fDelay, false, volumn);

        if (null != soundCreate)
        {
            soundCreate.transform.parent = this.transform;
            listSound.Add(soundCreate);
        }
        return(soundCreate);
    }