public void Play(SFXData data) { this.data = data; _duration = 9999f; if (data.ReferencedClip.Asset != null) { OnLoaded(data.ReferencedClip.Asset as AudioClip); } else if (data.ReferencedClip.OperationHandle.IsValid()) { if (data.ReferencedClip.OperationHandle.IsDone) { OnLoaded(data.ReferencedClip.OperationHandle.Result as AudioClip); } else { data.ReferencedClip.OperationHandle.Completed += h => OnLoaded(h.Result as AudioClip); } } else { try { data.ReferencedClip.LoadAssetAsync <AudioClip>().Completed += h => OnLoaded(h.Result); } catch (System.Exception) { } } }
public void Play(SFXData data, Transform parent) { Play(data); _source.spatialBlend = 1f; _transform.position = parent.position; _toFollow = parent; }
void ReleasePlayingClip(SFXData clip) { if (clip != null && _loadedClips.ContainsKey(clip)) { _loadedClips[clip] = Mathf.Max(0, _loadedClips[clip]); } }
public void PlaySFX(SFXData SFXType) { if (SFXSource != null) { SFXSource.mute = !EssentialData.Instance.LoadSettingSFX(); SFXSource.PlayOneShot(SFXClip[(int)SFXType - 1]); } }
public void Reset() { data = null; _source.Stop(); _looping = false; _elapsed = 0f; _duration = 0f; _toFollow = null; _transform.localPosition = Vector3.zero; gameObject.SetActive(false); Id = -1; }
public void Play(string name) { if (_playingClip != null && string.Equals(name, _playingClip.ClipName, StringComparison.InvariantCultureIgnoreCase)) { return; } if (_playingClip != null) { _source.Stop(); _playingClip.ReferencedClip.ReleaseAsset(); } if (string.IsNullOrEmpty(name)) { _playingClip = null; return; } var clip = _clipStorer.GetClipByName(name); _playingClip = clip; clip.ReferencedClip.LoadAssetAsync <AudioClip>().Completed += h => OnClipLoaded(h.Result); }
public void Play(SFXData data, Vector3 position) { Play(data); _source.spatialBlend = 1f; _transform.position = position; }
private void Awake() { audioSource = gameObject.AddComponent <AudioSource>(); settings = Resources.Load <SFXData>("SFXSettings"); }