Example #1
0
        void Init()
        {
            DontDestroyOnLoad(this.gameObject);

            string stKey = string.Format("{0}_SFXVol", gamePrefsName);

            if (PlayerPrefs.HasKey(stKey))
            {
                volume = PlayerPrefs.GetFloat(stKey);
            }
            else
            {
                volume = 0.5f;
            }

            soundObjectList = new List <SoundObject>();

            foreach (AudioClip theSound in gameSounds)
            {
                tempSoundObj = new SoundObject(theSound, theSound.name, volume);
                soundObjectList.Add(tempSoundObj);

                DontDestroyOnLoad(tempSoundObj.sourceGO);
            }
        }
Example #2
0
        public void PlaySoundByIndex(int anIndexNumber, Vector3 aPosition)
        {
            if (anIndexNumber > soundObjectList.Count)
            {
                anIndexNumber = soundObjectList.Count - 1;
            }

            tempSoundObj = soundObjectList[anIndexNumber];
            tempSoundObj.PlaySound(aPosition);
        }
Example #3
0
        public void UpdateVolume()
        {
            if (soundObjectList == null)
            {
                Init();
            }

            string stKey = string.Format("{0}_SFXVol", gamePrefsName);

            volume = PlayerPrefs.GetFloat(stKey);

            for (int i = 0; i < soundObjectList.Count; i++)
            {
                tempSoundObj = soundObjectList[i];
                tempSoundObj.source.volume = volume;
            }
        }