private void InitializeSounds() { _gameSounds = new List <SoundTypeList>(); SoundTypeList soundsList = null; int countOfTypes = Enum.GetNames(typeof(Enumerators.SoundType)).Length; for (int i = 0; i < countOfTypes; i++) { soundsList = new SoundTypeList(); soundsList.soundType = (Enumerators.SoundType)i; soundsList.audioTypeClips = LoadAudioClipsByType(soundsList.soundType); _gameSounds.Add(soundsList); } }
//NEW public AudioSource PlaySound(List <AudioClip> clips, Enumerators.SoundType soundType, int clipIndex = 0, int priority = 128, float volume = -1f, Transform parent = null, bool isLoop = false, bool isPlaylist = false, bool dropOldBackgroundMusic = true, bool returnHashCode = false) { if (dropOldBackgroundMusic) { var oldContainers = _soundContainers.FindAll(x => x.soundParameters.isBackground); foreach (var oldCotainer in oldContainers) { oldCotainer.audioSource.Stop(); oldCotainer.forceClose = true; } } SoundParam soundParam = new SoundParam(); SoundContainer container = new SoundContainer(); SoundTypeList soundTypeList = new SoundTypeList(); soundTypeList.soundType = soundType; soundTypeList.audioTypeClips = clips; soundParam.isBackground = soundType.ToString().Contains("BACKGROUND") ? true : false; soundParam.audioClips = soundTypeList.audioTypeClips; soundParam.isLoop = isLoop; soundParam.isMute = false; soundParam.playOnAwake = false; soundParam.priority = 128; soundParam.volume = volume; soundParam.startPosition = 0f; container.Init(_soundsRoot, soundType, soundParam, isPlaylist, clipIndex); if (parent != null) { container.container.transform.SetParent(parent); } _soundContainers.Add(container); return(container.audioSource); }