public void Play ( AudioSource _audioSource, ESoundType _soundType, string _clipName, bool _force ) { if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled ) { if ( _force ) { _audioSource.clip = GetAudioClip ( _clipName ); _audioSource.Play(); } else { if ( !_audioSource.isPlaying ) { _audioSource.clip = GetAudioClip ( _clipName ); _audioSource.Play(); } } } if ( _soundType == ESoundType.Music && m_musicEnabled ) { if ( _force ) { _audioSource.clip = GetAudioClip ( _clipName ); _audioSource.Play(); } else { if ( !_audioSource.isPlaying ) { _audioSource.clip = GetAudioClip ( _clipName ); _audioSource.Play(); } } } }
private OneShotSoundComponent PlaySound(AudioClip sound, ESoundType soundType, ESoundLocalizationType localizationType, Vector3 position, float minRange = 0f, float maxRange = 0f) { OneShotSoundComponent oneShotSound = null; GameObject instantiatedSource = Instantiate(m_AudioSourcePrefab); if (instantiatedSource.TryGetComponent(out AudioSource source)) { if (instantiatedSource.TryGetComponent(out oneShotSound)) { instantiatedSource.transform.position = position; source.clip = sound; source.spatialBlend = (localizationType == ESoundLocalizationType.Global) ? 0f : 1f; source.minDistance = (minRange == 0f && maxRange == 0f) ? /*GET DEFAULT VALUE FROM SETTINGS*/ 10f : minRange; source.maxDistance = (minRange == 0f && maxRange == 0f) ? /*GET DEFAULT VALUE FROM SETTINGS*/ 10f : maxRange; oneShotSound.SetSoundType(soundType); } else { DebugUtils.LogWarning(this, "AudioSourcePrefab has no OneShotSoundComponent, sound will not be played"); Destroy(instantiatedSource); } } else { DebugUtils.LogWarning(this, "AudioSourcePrefab has no AudioSource component, sound will not be played"); Destroy(instantiatedSource); } return(oneShotSound); }
public void SetPlayingSoundType(ESoundType soundType) { int nextPlayingSoundIndex = 0; _soundTypesIndexesDictionary.TryGetValue(soundType, out nextPlayingSoundIndex); _playingSoundIndex = nextPlayingSoundIndex; }
public void Play ( AudioSource _audioSource, ESoundType _soundType, bool _force ) { if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled ) { if ( _force ) { _audioSource.Play(); } else { if ( !_audioSource.isPlaying ) { _audioSource.Play(); } } } if ( _soundType == ESoundType.Music && m_musicEnabled ) { if ( _force ) { _audioSource.Play(); } else { if ( !_audioSource.isPlaying ) { _audioSource.Play(); } } } }
public void Play ( AudioSource _audioSource, ESoundType _soundType ) { if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled ) { _audioSource.Play(); } if ( _soundType == ESoundType.Music && m_musicEnabled ) { _audioSource.Play(); } }
public void PlaySound(ESoundType soundType) { var soundClip = _soundStore.Sounds.FirstOrDefault(s => s.soundType == soundType); if (soundClip.audioClips.Count > 0) { _audioSource.PlayOneShot(soundClip.audioClips[Random.Range(0, soundClip.audioClips.Count - 1)]); } else { Debug.LogError($"No sound found for {{soundType}}"); } }
public void PlaySound(string Name, ESoundType SoundType) { AudioClip LoadedClip = CResourceMgr.LoadSound(Name, SoundType); if (SoundType == ESoundType.BGM) { audioSource.clip = LoadedClip; audioSource.Play(); } else { audioSource.PlayOneShot(LoadedClip); } }
private void HookPlaySound(int oldSoundTypeIndex, int newSoundTypeIndex) { ESoundType correspondingSoundType = ESoundType.None; foreach (ESoundType soundType in Enum.GetValues(typeof(ESoundType))) { if (_soundTypesIndexesDictionary[soundType] == newSoundTypeIndex) { correspondingSoundType = soundType; _playingSoundType = correspondingSoundType; break; } } PlaySound(correspondingSoundType); }
public void PlaySound(ESoundType sfx) { SoundSource.clip = SoundList[(int)sfx]; // volume switch(sfx) { case ESoundType.SwipeDown: case ESoundType.SwipeUp: case ESoundType.SwipeSide: SoundSource.volume = 0.2f; break; default: SoundSource.volume = 1f; break; } SoundSource.Play(); }
public HierarchySoundSfxVoice(FArchive Ar) : base(Ar) { Ar.Position += 2; SoundConversion = Ar.Read <ESoundConversion>(); Ar.Position += 1; SoundSource = Ar.Read <ESoundSource>(); SoundId = Ar.Read <uint>(); SourceId = Ar.Read <uint>(); if (SoundSource == ESoundSource.Embedded) { WemOffset = Ar.Read <uint>(); WemLength = Ar.Read <uint>(); } SoundType = Ar.Read <ESoundType>(); //TODO }
public void PlaySound(ESoundType soundType) { SoundList soundList = _soundLists.Find((potentialSoundList) => potentialSoundList.SoundType == soundType); if (soundList == null) { return; } AudioClip clip = soundList.Sounds[UnityEngine.Random.Range(0, soundList.Sounds.Count)]; if (clip != null) { AudioSource.clip = clip; AudioSource.Play(); _timer = 0f; _currentAudioLength = clip.length; } }
public void PlaySound(ESoundType sfx) { SoundSource.clip = SoundList[(int)sfx]; // volume switch (sfx) { case ESoundType.SwipeDown: case ESoundType.SwipeUp: case ESoundType.SwipeSide: SoundSource.volume = 0.2f; break; default: SoundSource.volume = 1f; break; } SoundSource.Play(); }
/// <summary> /// Plays an <see cref="AudioClip"/> in 2D. /// </summary> /// <param name="clip">The <see cref="AudioClip"/> to play.</param> public void PlayGlobalSound(AudioClip clip, ESoundType soundType) { AudioSource audioSource = GetAvailableAudioSource(); audioSource.gameObject.SetActive(true); audioSource.clip = clip; audioSource.spatialBlend = 0.0f; audioSource.maxDistance = 5000; switch (soundType) { case ESoundType.Music: audioSource.outputAudioMixerGroup = musicMixer; break; case ESoundType.Sfx: audioSource.outputAudioMixerGroup = sfxMixer; break; } audioSource.Play(); }
public static AudioClip LoadSound(string name, ESoundType SoundType) { switch (SoundType) { case ESoundType.BGM: name = "Sound/BGM/" + name; break; case ESoundType.Item: name = "Sound/SFX/Item/" + name; break; case ESoundType.Motion: name = "Sound/SFX/Motion/" + name; break; case ESoundType.UI: name = "Sound/SFX/UI/" + name; break; } return(Resources.Load <AudioClip>(name)); }
private OneShotSoundComponent Play3DSound(AudioClip sound, ESoundType type, Vector3 position, float maxRange, float minRange) { return(PlaySound(sound, type, ESoundLocalizationType.Point, position, minRange, maxRange)); }
//PRIVATE private OneShotSoundComponent Play2DSound(AudioClip sound, ESoundType type) { return(PlaySound(sound, type, ESoundLocalizationType.Global, Vector3.zero)); }
/// <summary> /// Plays an <see cref="AudioClip"/> in 3D. /// </summary> /// <param name="clip">The <see cref="AudioClip"/> to play.</param> /// <param name="position">The position to play the clip at.</param> /// <param name="radius">How far away the <see cref="AudioClip"/> can be heard.</param> public void PlaySoundAtPosition(AudioClip clip, Vector3 position, float radius, ESoundType soundType) { AudioSource audioSource = GetAvailableAudioSource(); audioSource.gameObject.SetActive(true); audioSource.transform.position = position; audioSource.clip = clip; audioSource.spatialBlend = 1.0f; audioSource.maxDistance = radius; switch (soundType) { case ESoundType.Music: audioSource.outputAudioMixerGroup = musicMixer; break; case ESoundType.Sfx: audioSource.outputAudioMixerGroup = sfxMixer; break; } audioSource.Play(); }
//PUBLIC public void SetSoundType(ESoundType soundType) { m_SoundType = soundType; }
public void Play(ESoundType soundType) { audioSource.PlayOneShot(sounds.First(i => i.Type == soundType).Clip); }
public SoundPlayInfo(ESoundType eType) { Clear(); eSoundType = eType; }