예제 #1
0
        public int PlaySoundSingleton(string name, bool replace)
        {
            if (m_SingletonSoundMap.ContainsKey(name))
            {
                if (replace)
                {
                    m_SingletonSoundMap[name].Stop();
                    m_SingletonSoundMap.Remove(name);
                }
                else
                {
                    return(-1);
                }
            }

            int id = PlaySound(name, false);

            if (id < 0)
            {
                return(id);
            }

            AudioUnit unit = AudioUnit.GetAudioUnitByID(id);

            unit.SetOnStopListener(OnSingleAudioFinish);
            m_SingletonSoundMap.Add(name, unit);
            return(unit.id);
        }
예제 #2
0
        public int PlaySoundShoot(string name)
        {
            if (m_SingletonSoundMap.ContainsKey(name))
            {
                var unit = m_SingletonSoundMap[name];
                unit.PlayShoot();
                return(unit.id);
            }
            else
            {
                int id = PlaySound(name, false);

                if (id < 0)
                {
                    return(id);
                }

                AudioUnit unit = AudioUnit.GetAudioUnitByID(id);
                unit.SetOnStopListener(OnSingleAudioFinish);
                m_SingletonSoundMap.Add(name, unit);
                return(unit.id);
            }
        }