public void PlaySound3D(int audioClipId, Vector3 position, float volume, float pitch) { if (!GameData.Instance().M_SettingData.m_SoundOn) { return; } AudioClip ac = map [audioClipId]; if (ac != null) { if (waitPlaySoundData3Ds.Count < MAX_NUM) { PlaySoundData psd = PlaySoundData.Instance().pools.Obtain(); psd.clip = ac; psd.volume = volume; psd.pitch = pitch; psd.position = position; waitPlaySoundData3Ds.Add(psd); } } else { DebuggerUtil.LogError(" Sound Manager play3D, the audio clip is null"); } }
private void PlaySound(Bytes.Data data) { PlaySoundData soundData = (PlaySoundData)data; float vol = soundData.Volume * source.volume; if (soundData.Volume == -1) { vol = source.volume; } string variation = ""; if (soundData.NbVariations > 1) { variation = "_" + Random.Range(1, soundData.NbVariations).ToString(); } AudioClip clip = Resources.Load <AudioClip>("Sounds/" + soundData.Name + variation); if (clip != null) { source.PlayOneShot(clip, vol); } //else //Debug.LogError("Sounds/" + soundData.Name + " doesnt exist!"); }
public static PlaySoundData Instance() { if (g_Instance == null) { g_Instance = new PlaySoundData(); } return(g_Instance); }
private void PlaySound(Bytes.Data data) { PlaySoundData soundData = (PlaySoundData)data; float vol = source.volume / 2f; //if (soundData.Volume == -1) { vol = source.volume; } AudioClip clip = Resources.Load <AudioClip>("Sounds/" + soundData.Name); if (clip != null) { source.PlayOneShot(clip, vol); } //else //Debug.LogError("Sounds/" + soundData.Name + " doesnt exist!"); }
void Update_WaitPlaySound3D() { if (waitPlaySoundData3Ds.Count == 0) { return; } AudioSource source = GetFreeSource3D(); if (source != null) { PlaySoundData psd = waitPlaySoundData3Ds [0]; psd.Play(source); waitPlaySoundData3Ds.RemoveAt(0); PlaySoundData.Instance().pools.Free(psd); } }
public static PlaySoundData Instance () { if (g_Instance == null) g_Instance = new PlaySoundData (); return g_Instance; }