public void PlaySoundByIndex(int indexNumber, Vector3 position) { if (indexNumber > _soundObjectList.Count) { indexNumber = _soundObjectList.Count - 1; } _tempSoundObject = _soundObjectList[indexNumber]; _tempSoundObject.PlaySound(position); }
void Awake() { if (_instance == null) { _instance = this; } else { if (this != _instance) { Destroy(this.gameObject); } } Volume = PlayerPrefs.GetFloat(GamePrefsName + "_SFXVol", Volume); _soundObjectList = new List <SoundObject>(); foreach (var theSound in GameSounds) { _tempSoundObject = new SoundObject(theSound, theSound.name, Volume, this.gameObject); _soundObjectList.Add(_tempSoundObject); } }