private void HandlePlayEvent(AudioEvent audioEvent) { AudioAsset asset = ResolveAsset(audioEvent); if (!asset) { return; } _AudioChannelPool.Play(asset, audioEvent); }
public void Play(AudioAsset asset, AudioEvent audioEvent) { if (FindFreeChannel(out AudioChannel channel)) { channel.Play(asset, audioEvent); } else { Debug.LogWarningFormat("[Audio] All {0} channels(s) are full", _AudioChannels.Length); } }
public void ProcessEvent(AudioEvent audioParams) { switch (audioParams.AudioCommand) { case AudioCommands.PLAY: HandlePlayEvent(audioParams); break; case AudioCommands.STOP_CONTEXT: HandleStopEvent(audioParams); break; default: return; } }
public void Play(AudioAsset asset, AudioEvent audioEvent) { IsFree = false; if (audioEvent.FollowTransform) { _TransformFollower.StartFollowing(audioEvent.FollowTransform); } _GameObject.transform.position = audioEvent.WorldPosition; _Callbacks.OnUpdate -= Update; _Callbacks.OnUpdate += Update; _GameObject.SetActive(true); Context = audioEvent.Context; AudioSysUtil.ConfigureAudioSource(_AudioSource, asset); _AudioSource.Play(); _GameObject.name = $"Audio Channel {_ChannelNumber}: {audioEvent.Identifier}"; }
private AudioAsset ResolveAsset(AudioEvent audioEvent) { AudioAsset asset = null; for (int i = 0; i < _Libraries.Length; i++) { asset = _Libraries[i].Resolve(audioEvent.Identifier); if (asset) { break; } } #if DEBUG if (!asset) { AudioLog.Warning($"{audioEvent.Identifier} could not be found in any audio library."); } #endif return(asset); }
private void HandleStopEvent(AudioEvent audioEvent) { _AudioChannelPool.StopContext(audioEvent.Context); }
/// <summary> /// Used to send audio events inside of the audio /// </summary> /// <param name="audioParams"></param> public static void SendEvent(AudioEvent audioParams) { s_AudioManager.Value.ProcessEvent(audioParams); }