// public void Play(SoundKey key, Vector3 pos) { if (clips.ContainsKey(key) == false) { return; } // AudioSource playAudio = null; // foreach (AudioSource audio in fxAudios) { if (audio.gameObject.activeSelf == false) { playAudio = audio; break; } } // if (playAudio == null) { return; } // playAudio.gameObject.SetActive(true); // playAudio.transform.position = pos; playAudio.PlayOneShot(clips[key]); // AudioDisable(playAudio, clips[key].length); }
// Ignores Looping and SpatialBlend public void PlaySound(SoundKey soundKey) { Sound sound = System.Array.Find(gameSounds, s => s.soundKey == soundKey); if (sound != null) { if (CanPlaySound(sound)) { if (oneShotObj == null) { oneShotObj = new GameObject("Audio Manager One Shot Object"); oneShotObj.transform.parent = transform; oneShotAudioSource = oneShotObj.AddComponent <AudioSource>(); } // Audio Source Config oneShotAudioSource.volume = sound.volume; oneShotAudioSource.pitch = sound.pitch; oneShotAudioSource.spatialBlend = 0f; oneShotAudioSource.loop = false; oneShotAudioSource.PlayOneShot(sound.clip, sound.volume); } } else { Debug.LogError("Sound " + soundKey + "not found!"); } }
public SoundEffectInstance GetSound(SoundKey key) { SoundEffectInstance sound = null; soundMap.TryGetValue(key, out sound); return(sound); }
public void Play(SoundKey key, Vector3 pos) { if (!clips.ContainsKey(key)) { return; } AudioSource playAudio = null; foreach (AudioSource audio in fxAudios) { if (!audio.gameObject.activeSelf) { playAudio = audio; break; } } if (playAudio == null) { return; } playAudio.gameObject.SetActive(true); playAudio.transform.position = pos; playAudio.PlayOneShot(clips[key]); StartCoroutine(AudioDisable(playAudio, clips[key].length)); }
public void PlaySound(SoundKey key) { CheckDisposed(); Cue sound = m_soundBank.GetCue(key.ToString()); sound.Play(); }
protected void RegisterSound(SoundKey key, SoundEffectInstance sound) { if (sound == null) { throw new ArgumentNullException("sound"); } soundMap[key] = sound; }
public void PlayBgm(SoundKey key) { if (!clips.ContainsKey(key)) { return; } bgAudio.clip = clips[key]; bgAudio.Play(); }
protected void DeregisterSound(SoundKey key) { SoundEffectInstance sound; if (soundMap.TryGetValue(key, out sound)) { sound.Dispose(); } soundMap.Remove(key); }
private void AddKey(float time) { SoundKey newKey = ScriptableObject.CreateInstance <SoundKey>(); newKey.Clip = null; newKey.FireTime = time; EventOrientedKeyView e = CreateEvent(newKey); RebuildTrackKeys(); InspectorProperties.Select(e); }
// public void PlayBGR(SoundKey key) { if (clips.ContainsKey(key) == false) { return; } // bgAuido.clip = clips[key]; // if (bgAuido.isPlaying == false) { bgAuido.Play(); } }
protected void RegisterSound(SoundKey key, string asset) { if (asset == null) { throw new ArgumentNullException("asset"); } try { var soundEffect = Content.Load <SoundEffect>(asset); soundMap[key] = soundEffect.CreateInstance(); } catch (ContentLoadException) { } }
public SoundKeyView(SoundTrackBar trackBar, SoundKey key) : base(trackBar, key) { this._SoundKey = key; _PreviewImage = new AudioPreviewCurve() { Margin = new Skill.Framework.UI.Thickness(2), BackgroundColor = Color.clear }; _LblClipName = new Skill.Framework.UI.Label() { Style = Resources.Styles.EventLabel }; Controls.Add(_PreviewImage); Controls.Add(_LblClipName); }
// public void Play(SoundKey key, int audioIndex, bool loop = false) { AudioSource playAudio = null; playAudio = fxAudios[(fxAudios.Count - 1) - audioIndex]; // if (loop == true) { if (playAudio.isPlaying == true) { return; } } // playAudio.gameObject.SetActive(true); playAudio.PlayOneShot(clips[key]); AudioDisable(playAudio, clips[key].length); }
public AudioSource PlaySound(SoundKey soundKey, Vector3 position) { Sound sound = System.Array.Find(gameSounds, s => s.soundKey == soundKey); if (sound != null) { if (CanPlaySound(sound)) { GameObject soundGameObject = new GameObject("Audio Manager 3D Object"); soundGameObject.transform.position = position; soundGameObject.transform.parent = transform; AudioSource audioSource = soundGameObject.AddComponent <AudioSource>(); // Audio Source Config audioSource.clip = sound.clip; audioSource.volume = sound.volume; audioSource.pitch = sound.pitch; audioSource.spatialBlend = sound.spatialBlend; audioSource.loop = sound.loop; if (sound.loop) { audioSource.Play(); return(audioSource); } else { audioSource.Play(); Object.Destroy(soundGameObject, audioSource.clip.length); return(audioSource); // TODO: To improve performace: Object Pooling } } else { return(null); } } else { Debug.LogError("Sound " + soundKey + "not found!"); return(null); } }
public void Play(SoundKey key, Transform target = null) { if (!clips.ContainsKey(key)) { return; } AudioSource playAudio = null; foreach (AudioSource audio in fxAudios) { if (!audio.gameObject.activeSelf) { playAudio = audio; break; } } if (playAudio == null) { return; } playAudio.gameObject.SetActive(true); if (transform == null) { playAudio.transform.SetParent(Camera.main.transform); } else { playAudio.transform.SetParent(target); } playAudio.transform.localPosition = Vector3.zero; playAudio.PlayOneShot(clips[key]); StartCoroutine(AudioDisable(playAudio, clips[key].length)); }
// public void Play(SoundKey key, Transform target = null, float effVol = -1.0f) { if (clips.ContainsKey(key) == false) { return; } // AudioSource playAudio = null; // foreach (AudioSource audio in fxAudios) { if (audio.gameObject.activeSelf == false) { playAudio = audio; break; } } if (playAudio == null) { return; } // playAudio.gameObject.SetActive(true); // if (target != null) { playAudio.transform.SetParent(target); } // playAudio.transform.localPosition = Vector3.zero; // playAudio.PlayOneShot(clips[key]); // AudioDisable(playAudio, clips[key].length); }
public SoundEffectInstance GetSound(SoundKey key) { SoundEffectInstance sound = null; soundMap.TryGetValue(key, out sound); return sound; }
protected void RegisterSound(SoundKey key, SoundEffectInstance sound) { if (sound == null) throw new ArgumentNullException("sound"); soundMap[key] = sound; }
protected void RegisterSound(SoundKey key, string asset) { if (asset == null) throw new ArgumentNullException("asset"); try { var soundEffect = Content.Load<SoundEffect>(asset); soundMap[key] = soundEffect.CreateInstance(); } catch (ContentLoadException) { } }
protected void DeregisterSound(SoundKey key) { SoundEffectInstance sound; if (soundMap.TryGetValue(key, out sound)) sound.Dispose(); soundMap.Remove(key); }