Exemplo n.º 1
0
        public override void OnSingletonInit()
        {
            m_IsSoundEnable = PlayerPrefs.GetInt(SOUND_STATE_RECORD_KEY, 1) > 0;
            m_IsMusicEnable = PlayerPrefs.GetInt(MUSIC_STATE_RECORD_KEY, 1) > 0;

            ObjectPool <AudioUnit> .S.Init(m_MaxCacheSoundCount, 1);

            m_MainUnit           = AudioUnit.Allocate();
            m_MainUnit.usedCache = false;
        }
Exemplo n.º 2
0
        public int PlaySound(string name, bool loop = false, Action <int> callBack = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(-1);
            }

            AudioUnit unit = AudioUnit.Allocate();

            if (unit == null)
            {
                return(-1);
            }

            unit.SetAudio(gameObject, name, loop, m_IsSoundEnable);
            unit.SetOnFinishListener(callBack);
            return(unit.id);
        }