SFXData GetClipToPlay(string name) { foreach (var kvp in _loadedClips) { if (kvp.Key.ClipName.Equals(name)) { _loadedClips[kvp.Key] += 1; return(kvp.Key); } } var sfx = _clipStorer.GetClipByName(name); _loadedClips.Add(sfx, 1); return(sfx); }
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); }