Beispiel #1
0
 private void checkForFadeOut(UnityEngine.Playables.Playable playable)
 {
     if (eventTracker != null && !eventTracker.fadeoutTriggered && fadeOutRequired(playable))
     {
         requiredActions |= AkPlayableAction.FadeOut;
     }
 }
Beispiel #2
0
 private void checkForFadeIn(float currentClipTime)
 {
     if (fadeInRequired(currentClipTime))
     {
         requiredActions |= AkPlayableAction.FadeIn;
     }
 }
Beispiel #3
0
 public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info)
 {
     if (akEvent != null)
     {
         if (ShouldPlay(playable))
         {
             requiredActions |= AkPlayableAction.Playback;
             // If we've explicitly set the playhead, only play a small snippet.
             // We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode.
             // This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0
             if (info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate &&
                 UnityEngine.Application.isPlaying)
             {
                 requiredActions |= AkPlayableAction.DelayedStop;
                 checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable));
                 checkForFadeOut(playable);
             }
             else
             {
                 var proportionalTime = getProportionalTime(playable);
                 var alph             = 0.05f;
                 // we need to jump to the correct position in the case where the event is played from some non-start position.
                 if (proportionalTime > alph)
                 {
                     requiredActions |= AkPlayableAction.Seek;
                 }
                 checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable));
                 checkForFadeOut(playable);
             }
         }
     }
 }
Beispiel #4
0
    public override void PrepareFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info)
    {
        if (eventTracker != null)
        {
            // We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode.
            // This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0
            var scrubbing = info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate &&
                            UnityEngine.Application.isPlaying;
            if (scrubbing && ShouldPlay(playable))
            {
                if (!eventTracker.eventIsPlaying)
                {
                    requiredActions |= AkPlayableAction.Playback;
                    requiredActions |= AkPlayableAction.DelayedStop;
                    checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable));
                    checkForFadeOut(playable);
                }

                requiredActions |= AkPlayableAction.Seek;
            }
            else             // The clip is playing but the event hasn't been triggered. We need to start the event and jump to the correct time.
            {
                if (!eventTracker.eventIsPlaying && (requiredActions & AkPlayableAction.Playback) == 0)
                {
                    requiredActions |= AkPlayableAction.Retrigger;
                    checkForFadeIn((float)UnityEngine.Playables.PlayableExtensions.GetTime(playable));
                }

                checkForFadeOut(playable);
            }
        }
    }
Beispiel #5
0
    public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info,
                                      object playerData)
    {
        if (!overrideTrackEmittorObject)
        {
            var obj = playerData as UnityEngine.GameObject;
            if (obj != null)
            {
                eventObject = obj;
            }
        }

        if (eventObject != null)
        {
            var clipTime = (float)UnityEngine.Playables.PlayableExtensions.GetTime(playable);
            if (actionIsRequired(AkPlayableAction.Playback))
            {
                playEvent();
            }
            if (eventShouldRetrigger && actionIsRequired(AkPlayableAction.Retrigger))
            {
                retriggerEvent(playable);
            }
            if (actionIsRequired(AkPlayableAction.Stop))
            {
                akEvent.Stop(eventObject);
            }
            if (actionIsRequired(AkPlayableAction.DelayedStop))
            {
                stopEvent(scrubPlaybackLengthMs);
            }
            if (actionIsRequired(AkPlayableAction.Seek))
            {
                seekToTime(playable);
            }
            if (actionIsRequired(AkPlayableAction.FadeIn))
            {
                triggerFadeIn(clipTime);
            }
            if (actionIsRequired(AkPlayableAction.FadeOut))
            {
                var timeLeft = (float)(UnityEngine.Playables.PlayableExtensions.GetDuration(playable) -
                                       UnityEngine.Playables.PlayableExtensions.GetTime(playable));
                triggerFadeOut(timeLeft);
            }
        }

        requiredActions = (uint)AkPlayableAction.None;
    }
Beispiel #6
0
 private bool actionIsRequired(AkPlayableAction actionType)
 {
     return((requiredActions & (uint)actionType) != 0);
 }
Beispiel #7
0
 private bool actionIsRequired(AkPlayableAction actionType)
 {
     return((requiredActions & actionType) == actionType);
 }