示例#1
0
        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);
     }
 }
示例#3
0
        public void ProcessEvent(AudioEvent audioParams)
        {
            switch (audioParams.AudioCommand)
            {
            case AudioCommands.PLAY:
                HandlePlayEvent(audioParams);
                break;

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

            default:
                return;
            }
        }
示例#4
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}";
        }
示例#5
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;
                }
            }
#if DEBUG
            if (!asset)
            {
                AudioLog.Warning($"{audioEvent.Identifier} could not be found in any audio library.");
            }
#endif
            return(asset);
        }
示例#6
0
 private void HandleStopEvent(AudioEvent audioEvent)
 {
     _AudioChannelPool.StopContext(audioEvent.Context);
 }
示例#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);
 }