public AudioSource StartLoop(AudioClip AC, Transform t, string key, SOUNDSETTING soundSetting) { if (_loops.ContainsKey(t)) { if (_loops[t].ContainsKey(key)) { return(_loops[t][key]); } } else { _loops.Add(t, new Dictionary <string, AudioSource>()); } // create object Transform tObj = Core.Pool.Spawn(_audioTransform); // set parent tObj.position = t.position; tObj.parent = t; // get the source AudioSource AS = tObj.GetComponent <AudioSource>(); // play the sound AS.clip = AC; AS.loop = true; AS.volume = GetVolume(soundSetting); AS.Play(); _loops[t].Add(key, AS); return(AS); // return null; }
public void PlaySound(AudioClip AC, Transform t, SOUNDSETTING soundSetting, bool soundOcclusion = false) { if (AC == null) { return; } // create object Transform tObj = Core.Pool.Spawn(GetTransform(soundOcclusion)); // set parent tObj.position = t.position; if (soundOcclusion) { tObj.GetComponent <RealSound>().StartSound(t, AC, GetVolume(soundSetting)); } else { tObj.parent = t; // play sound if (!tObj.GetComponent <AudioSource>().isPlaying) { tObj.GetComponent <AudioSource>().PlayOneShot(AC, GetVolume(soundSetting)); } } // remove obejct Core.Pool.Remove(tObj, AC.length); }
public AudioClip PlaySound(AudioClip AC, SOUNDSETTING soundSetting) { if (AC == null) { return(null); } // play sound on main camera object //GameData.GetCamera(0).cameraComponent.GetComponent<AudioSource>().PlayOneShot(AC, GetVolume(soundSetting)); //Debug.Log("Source: " + _audioSource + " clip: " + AC); _audioSource.PlayOneShot(AC, GetVolume(soundSetting)); return(AC); }
public void PlaySound(AudioClip AC, Vector3 pos, SOUNDSETTING soundSetting) { if (AC == null) { return; } // create object Transform tObj = Core.Pool.Spawn(_audioTransform); // set position tObj.position = pos; // play sound tObj.GetComponent <AudioSource>().PlayOneShot(AC, GetVolume(soundSetting)); // remove obejct Core.Pool.Remove(tObj, AC.length); }
private float GetVolume(SOUNDSETTING soundSetting) { switch (soundSetting) { case SOUNDSETTING.MUSIC: return(Settings.soundMusic); case SOUNDSETTING.SFX: return(Settings.soundFX); case SOUNDSETTING.SPEAK: return(Settings.soundSpeak); default: return(1f); } }
public void SetLoopSound(Transform t, string key, SOUNDSETTING soundSetting) { // get the AS AudioSource AS = GetLoop(t, key); if (GetVolume(soundSetting) != 0) { AS.gameObject.SetActive(true); // set volume AS.volume = GetVolume(soundSetting); } else { GetLoop(t, key).gameObject.SetActive(false); } }
public AudioClip PlaySound(List <AudioClip> ACList, SOUNDSETTING soundSetting) { return(PlaySound(GetRandomAudioClip(ACList), soundSetting)); }
public void SetVolume(AudioSource AS, float volume, SOUNDSETTING setting) { AS.volume = volume * GetVolume(setting); }
public void SetVolume(AudioSource AS, float volume, float time, SOUNDSETTING setting, System.Action <float> update) { LeanTween.value(gameObject, update, AS.volume * GetVolume(SOUNDSETTING.MUSIC), volume, time).setEase(LeanTweenType.easeInOutQuad); }