Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        private void HandlePlayEvent(AudioEvent audioEvent)
        {
            AudioAsset asset = ResolveAsset(audioEvent);

            if (!asset)
            {
                return;
            }

            _AudioChannelPool.Play(asset,
                                   audioEvent);
        }
Exemplo n.º 3
0
        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;
                }
            }

            AudioLog.Assert(asset, $"{audioEvent.Identifier} could not be found in any audio library.");
            return(asset);
        }
Exemplo n.º 4
0
        public void ProcessEvent(AudioEvent audioParams)
        {
            switch (audioParams.AudioCommand)
            {
            case AudioCommands.PLAY:
                HandlePlayEvent(audioParams);
                break;

            case AudioCommands.STOP_CONTEXT:
                HandleStopEvent(audioParams);
                break;

            default:
                return;
            }
        }
Exemplo n.º 5
0
        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}";
        }
Exemplo n.º 6
0
 private void HandleStopEvent(AudioEvent audioEvent)
 {
     _AudioChannelPool.StopContext(audioEvent.Context);
 }
Exemplo n.º 7
0
 /// <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);
 }