bool DetectOutOfSync(Playable playable)
        {
            double expectedTime = playable.GetTime();

            if (playable.GetTime() >= m_AssetDuration)
            {
                if (director.extrapolationMode == DirectorWrapMode.None)
                {
                    return(false);
                }
                else if (director.extrapolationMode == DirectorWrapMode.Hold)
                {
                    expectedTime = m_AssetDuration;
                }
                else if (m_AssetDuration > float.Epsilon) // loop
                {
                    expectedTime = expectedTime % m_AssetDuration;
                }
            }

            if (!Mathf.Approximately((float)expectedTime, (float)director.time))
            {
#if UNITY_EDITOR
                double lastDelta = playable.GetTime() - playable.GetPreviousTime();
                if (UnityEditor.Unsupported.IsDeveloperBuild())
                {
                    Debug.LogWarningFormat("Internal Warning - Control track desync detected on {2} ({0:F10} vs {1:F10} with delta {3:F10}). Time will be resynchronized. Known to happen with nested control tracks", playable.GetTime(), director.time, director.name, lastDelta);
                }
#endif
                return(true);
            }
            return(false);
        }
예제 #2
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (!Application.isPlaying && !invokeAtEditTime)
            {
                return;
            }

            var recording = playerData as MethodRecording;

            if (recording == null)
            {
                return;
            }

            if (recording.mode != MethodRecording.Mode.Playback)
            {
                recording.EnterPlaybackMode();
            }

            float prevTime = (float)playable.GetPreviousTime();
            float nowTime  = (float)playable.GetTime();
            bool  didSeek  = _prevTime != playable.GetPreviousTime() || nowTime < prevTime;

            if (!didSeek)
            {
                recording.SweepTime(prevTime, nowTime);
            }

            _prevTime = playable.GetTime();
        }
예제 #3
0
 public override void PrepareFrame(Playable playable, 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
         bool scrubbing = info.evaluationType == FrameData.EvaluationType.Evaluate && Application.isPlaying;
         if (scrubbing && ShouldPlay(playable))
         {
             if (!eventTracker.eventIsPlaying)
             {
                 requiredActions |= (uint)AkPlayableAction.Playback;
                 requiredActions |= (uint)AkPlayableAction.DelayedStop;
                 checkForFadeIn((float)playable.GetTime());
                 checkForFadeOut(playable);
             }
             requiredActions |= (uint)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 & (uint)AkPlayableAction.Playback) == 0)
             {
                 requiredActions |= (uint)AkPlayableAction.Retrigger;
                 checkForFadeIn((float)playable.GetTime());
             }
             checkForFadeOut(playable);
         }
     }
 }
예제 #4
0
 public override void OnBehaviourPlay(Playable playable, FrameData info)
 {
     if (akEvent != null)
     {
         if (ShouldPlay(playable))
         {
             requiredActions |= (uint)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 == FrameData.EvaluationType.Evaluate && Application.isPlaying)
             {
                 requiredActions |= (uint)AkPlayableAction.DelayedStop;
                 checkForFadeIn((float)playable.GetTime());
                 checkForFadeOut(playable);
             }
             else
             {
                 float proportionalTime = getProportionalTime(playable);
                 float alph             = 0.05f;
                 if (proportionalTime > alph) // we need to jump to the correct position in the case where the event is played from some non-start position.
                 {
                     requiredActions |= (uint)AkPlayableAction.Seek;
                 }
                 checkForFadeIn((float)playable.GetTime());
                 checkForFadeOut(playable);
             }
         }
     }
 }
예제 #5
0
        // TODO 整理
        public override async void PrepareFrame(Playable playable, FrameData info)
        {
            if (video == null)
            {
                return;
            }

            if (PlayingState.IsPlayingTimelineInEditor && !video.isPlaying)
            {
                video.time = playable.GetTime();
                video.Play();
            }

            if (PlayingState.IsScrubbing)
            {
                video.time = playable.GetTime();
            }
            if (PlayingState.IsRecording && video.isPrepared)
            {
                video.time = playable.GetTime();
            }

            mat.mainTexture = video.texture;

            if (PlayingState.IsScrubbing)
            {
                video.Play();
                await UniTask.Delay(300);

                video.Pause();
            }
        }
예제 #6
0
//----------------------------------------------------------------------------------------------------------------------        
    

    public override void ProcessFrame(Playable playable, FrameData info, object playerData) {
        if (m_sceneCachePlayer.IsNullRef()) {
            return;
        }
        AnimationCurve curve = m_clipData.GetAnimationCurve();

        float normalizedTime = 0;
        switch (m_snapToFrame) {
            case SnapToFrame.NONE: {
                normalizedTime = curve.Evaluate((float) playable.GetTime());
                break;                 
            }
            case SnapToFrame.NEAREST: {

                TrackAsset trackAsset = m_clipData.GetOwner().GetParentTrack();
                if (null == trackAsset) {
                    return;
                }
                     
                float fps = (float) trackAsset.timelineAsset.editorSettings.GetFPS();
                
                float timePerFrame = 1.0f / fps;
                int   frame        = Mathf.RoundToInt((float)playable.GetTime() * fps);
                normalizedTime = curve.Evaluate(frame * timePerFrame);
                break;
            }            
        }
              
        m_sceneCachePlayer.RequestNormalizedTime(normalizedTime);

    }
예제 #7
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        Debug.Log(MethodInfo.GetCurrentMethod().Name + " Time=" + playable.GetTime());

        double preTime      = playable.GetPreviousTime();
        double timeOnClip   = playable.GetTime();
        double deltaTime    = timeOnClip - preTime;
        double durationTime = playable.GetDuration();
        double rate         = timeOnClip / durationTime;
        double rateAfter    = (timeOnClip + deltaTime) / durationTime;

        double weight = info.weight;

        int inputCount  = playable.GetInputCount();
        int outputCount = playable.GetOutputCount();

        Debug.Log(MethodInfo.GetCurrentMethod().Name + " InputCount=" + inputCount);

        // 文字列を設定
        messageDialog.SetText(textString);

        // 表示する
        messageDialog.Show();


        // ★次のフレームで完了する(クリップから抜ける)時
        // ※クリップを抜けるとProcessFrameは呼ばれず、OnBehaviourPauseが呼ばれるので、
        // ProcessFrame内で捕まえるタイミングは今しかない。
        if (rate < 1.0f && 1.0f <= rateAfter)
        {
            OnBehaviourPreFinish(playable, info, playerData);
        }
    }
예제 #8
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                if (_subject == null || playable.GetTime() <= 0)
                {
                    return;
                }

                float f = (float)(playable.GetTime() / playable.GetDuration()) * info.weight;

                if (useQuaternion)
                {
                    if (isLocal)
                    {
                        _subject.localRotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(f));
                    }
                    else
                    {
                        _subject.rotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(f));
                    }
                }
                else
                {
                    if (isLocal)
                    {
                        _subject.localEulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(f));
                    }
                    else
                    {
                        _subject.eulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(f));
                    }
                }
            }
        private bool DetectOutOfSync(Playable playable)
        {
            double num = playable.GetTime();

            if (playable.GetTime() >= m_AssetDuration)
            {
                if (director.extrapolationMode == DirectorWrapMode.None)
                {
                    return(false);
                }
                if (director.extrapolationMode == DirectorWrapMode.Hold)
                {
                    num = m_AssetDuration;
                }
                else if (m_AssetDuration > 1.4012984643248171E-45)
                {
                    num %= m_AssetDuration;
                }
            }
            if (!Mathf.Approximately((float)num, (float)director.time))
            {
                return(true);
            }
            return(false);
        }
예제 #10
0
    //Each frame of the behaviour
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        m_TrackBinding = playerData as RPGTalk;
        if (!m_FirstFrameHappened)
        {
            OnBehaviourPlay(playable, info);
            return;
        }



        //for now, we wont support spped changes into timeline
        if (m_TrackBinding.actualTextSpeed != textSpeed)
        {
            m_TrackBinding.actualTextSpeed = textSpeed;
        }

        //The current character will be calculated based on the textspeed and the time of the playable
        float currentChar = m_TrackBinding.actualTextSpeed * (float)playable.GetTime();



        //only change it if there is something new to change and we are not paused
        if (m_TrackBinding.rpgtalkElements.Count > m_TrackBinding.cutscenePosition - 1 &&
            Mathf.Min(currentChar, m_TrackBinding.rpgtalkElements [m_TrackBinding.cutscenePosition - 1].dialogText.Length)
            != m_TrackBinding.currentChar)
        {
            if (!rpgTime || !rpgTime.isPaused)
            {
                m_TrackBinding.currentChar = currentChar;
                m_TrackBinding.PutRightTextToShow();
            }
        }

        //If we reached the final, check if we should pause the timeline until the player finish the talk
        if (playable.GetTime() >= playable.GetDuration() - (double)0.1)
        {
            if (!reachedFinal)
            {
                reachedFinal = true;
                if (pauseUntilTalkEnd)
                {
                    if (!rpgTime)
                    {
                        Debug.LogError("To use the option 'Pause Until Talk End' the RpgTalk must contain a RPGTalkTimeline Component");
                    }
                    else
                    {
                        rpgTime.Pause();
                    }
                }
            }
        }
        else
        {
            reachedFinal = false;
        }
    }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if ((int)m_PreviousTime < (int)playable.GetTime())
            {
                info.output.PushNotification(playable, new MyNotification());
            }

            m_PreviousTime = playable.GetTime();
        }
예제 #12
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                if (_subject == null || playable.GetTime() <= 0)
                {
                    return;
                }

                float f = (float)(playable.GetTime() / playable.GetDuration()) * info.weight;

                _subject.color = Color.Lerp(src, dst, curve.Evaluate(f));
            }
예제 #13
0
    public virtual void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //This checks if we're actually playing. Prevents it running before the clip has started.

        if (playable.GetTime() == 0)
        {
            return;
        }

        Time.timeScale = Mathf.Lerp(_originalTimeScale, targetTimeScale, (float)(playable.GetTime() / playable.GetDuration()));
    }
예제 #14
0
 public float GetPercent(Playable playable)
 {
     if (m_revert)
     {
         return(1f - (float)playable.GetTime() / m_duration);
     }
     else
     {
         return((float)playable.GetTime() / m_duration);
     }
 }
 // Called each frame while the state is set to Play
 public override void PrepareFrame(Playable playable, FrameData info)
 {
     switch(type)
     {
         case DynamicTrackType.MouseX:
             SuperInput.SetMouseX(curve.Evaluate((float)playable.GetTime()), this);
             break;
         case DynamicTrackType.MouseY:
             SuperInput.SetMouseY(curve.Evaluate((float)playable.GetTime()), this);
             break;
     }
 }
예제 #16
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        float duration   = (float)playable.GetDuration();
        float passedTime = (float)playable.GetTime();

        Debug.Log("Playable get time " + playable.GetTime());
        Debug.Log("Playable duration " + playable.GetDuration());

        float t = duration - passedTime;

        Vector3 change = position - initialPosition;

        trasnform.position = Equations.ChangeVector(t, position, change, duration, Ease.Linear);
    }
예제 #17
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        double time = playable.GetTime();

        MidiEventReceiver trackBinding = playerData as MidiEventReceiver;

        if (!trackBinding)
        {
            return;
        }

        m_midiEventReceiver = trackBinding;

        //  Debug.Log( playable.GetGraph().GetRootPlayable(0).GetPlayState() );

        // Debug.Log(m_previousState);

        if (Director.state == PlayState.Paused)
        {
            m_lastTime = playable.GetTime();
            // DispatchEvents(m_seq.Start((float)playable.GetTime()));
        }
        // On play
        if (Director.state == PlayState.Playing && m_previousState == PlayState.Paused)
        {
            if (m_seq != null)
            {
                Debug.Log("Start it " + m_lastTime);
                LoadSong();
                LoadSequencer();
                DispatchEvents(m_seq.Start((float)m_lastTime));
            }
        }
        m_previousState = Director.state;


        if (!m_FirstFrameHappened)
        {
            m_FirstFrameHappened = true;
        }


        if (m_seq != null && m_seq.Playing)
        {
            // Update the sequencer and dispatch incoming events.

            DispatchEvents(m_seq.Advance(info.deltaTime));
        }
    }
예제 #18
0
 public sealed override void PrepareFrame(Playable playable, FrameData info)
 {
     if (this.m_HasFired)
     {
         if (this.HasLooped(playable.GetTime <Playable>(), info) || this.CanRestoreEvent(playable.GetTime <Playable>(), info))
         {
             this.Restore_internal();
         }
     }
     if (!this.m_HasFired && this.CanTriggerEvent(playable.GetTime <Playable>(), info))
     {
         this.Trigger_internal();
     }
     this.m_PreviousTime = playable.GetTime <Playable>();
 }
    // Called each frame while the state is set to Play
    public override void PrepareFrame(Playable playable, FrameData info)
    {
        // Debug.Log ("SimplePlayableBehaviour.PrepareFrame");
        float normTime = (float)(playable.GetTime() / playable.GetDuration());

        cubeObject.transform.position = new Vector3(4.0f, 2.0f * normTime, 0.0f);
    }
예제 #20
0
파일: DSP.cs 프로젝트: asophy/MyMusic
    public override void PrepareFrame(Playable playable, FrameData info)
    {
        float blend = Mathf.PingPong((float)playable.GetTime(), 1.0f);


        base.PrepareFrame(playable, info);
    }
예제 #21
0
        // Token: 0x06000225 RID: 549 RVA: 0x0000AB2F File Offset: 0x00008D2F
        public override void OnPlayableDestroy(Playable playable)
        {
            if (this.m_Instance)
            {
                if (Application.isPlaying)
                {
                    var timer = (float)playable.GetTime();
                    if (m_realLife > timer)
                    {
                        var lifeCtrl = this.m_Instance.AddComponent <ParticleLifeControl>();

                        //lifeCtrl.life = m_realLife - timer;
                        //lifeCtrl.flyDuration = m_duration - timer;
                        //lifeCtrl.TargetTrans = m_revert ? m_StartTrans : m_EndTrans;
                        lifeCtrl.InitFlyTarget(m_realLife - timer,
                                               m_revert ? m_StartTrans : m_EndTrans,
                                               m_duration - timer
                                               );
                    }
                    else
                    {
                        Object.Destroy(this.m_Instance);
                    }
                }
                else
                {
                    Object.DestroyImmediate(this.m_Instance);
                }
            }
        }
        void Update(Playable playable, FrameData info)
        {
            if (!Parent)
            {
                return;
            }

            var time = playable.GetTime();

            int index = Mathf.FloorToInt((float)(time * FPS)) % FrameIndices.Count;

            int currentIndex = FrameIndices[index];

            for (int i = 0; i < frameTransforms.Count; i++)
            {
                frameTransforms[i].gameObject.SetActive(i == currentIndex);
            }

            block.SetFloat("_FadeIn", info.effectiveWeight);
            block.SetFloat("_FadeOut", 1 /*info.effectiveWeight*/);
            block.SetInt("_FadeModeIn", (int)FadeIn);
            block.SetInt("_FadeModeOut", (int)FadeOut);
            foreach (var r in renderers)
            {
                r.SetPropertyBlock(block);
            }
        }
예제 #23
0
 public override void PrepareFrame(Playable playable, FrameData info)
 {
     if (this.m_timeControl != null)
     {
         this.m_timeControl.SetTime(playable.GetTime <Playable>());
     }
 }
예제 #24
0
        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
            base.OnBehaviourPause(playable, info);
            firstFrameHappened = false;

            var duration = playable.GetDuration();

            var time  = playable.GetTime();
            var delta = info.deltaTime;

            if (info.evaluationType == FrameData.EvaluationType.Playback)
            {
                var count = time + delta;

                if (count >= duration)
                {
                    TimelineManager.instance.Pause();
                }
            }

            //if (chatInteraction == null)
            //{
            //    return;
            //}
            //chatInteraction.transform.position = defaultPos;
        }
예제 #25
0
 public override void ProcessFrame(Playable playable, FrameData info, object playerData)
 {
     if (clip != null)
     {
         PlayClip((float)playable.GetTime());
     }
 }
예제 #26
0
        public override void PrepareFrame(Playable playable, UnityEngine.Playables.FrameData info)
        {
            if ((UnityEngine.Object) this.director == (UnityEngine.Object)null || !this.director.isActiveAndEnabled || (UnityEngine.Object) this.director.playableAsset == (UnityEngine.Object)null)
            {
                return;
            }
            if (this.director.playableGraph.IsValid())
            {
                int rootPlayableCount = this.director.playableGraph.GetRootPlayableCount();
                for (int index = 0; index < rootPlayableCount; ++index)
                {
                    Playable rootPlayable = this.director.playableGraph.GetRootPlayable(index);
                    if (rootPlayable.IsValid <Playable>())
                    {
                        rootPlayable.SetSpeed <Playable>((double)info.effectiveSpeed);
                        for (int i = 0; i < rootPlayable.GetInputCount(); i++)
                        {
                            rootPlayable.SetInputWeight(i, info.effectiveWeight);
                        }
                    }
                }
            }

            this.m_Time = playable.GetTime <Playable>();
            this.UpdateTime(playable);
        }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            var target = playerData as Transform;

            if (target == null)
            {
                return;
            }

            var t = (float)playable.GetTime() * frequency;
            var w = info.weight / 0.75f; // normalized weight

            var np = math.float3(
                Fbm(_positionOffset.x, t, octaves),
                Fbm(_positionOffset.y, t, octaves),
                Fbm(_positionOffset.z, t, octaves)
                );

            var nr = math.float3(
                Fbm(_rotationOffset.x, t, octaves),
                Fbm(_rotationOffset.y, t, octaves),
                Fbm(_rotationOffset.z, t, octaves)
                );

            np = np * positionAmount * w;
            nr = nr * rotationAmount * w;

            target.localPosition += (Vector3)np;
            target.localRotation  = Quaternion.Euler(nr) * target.localRotation;
        }
        /// <summary>
        /// Update the animation/FSM state for the player.
        /// </summary>
        /// <param name="player">The player character.</param>
        /// <param name="driver">The state driver for the target state.</param>
        /// <param name="playable">The playable associated with this clip.</param>
        /// <param name="pose">Information about the player's pose.</param>
        private void UpdateState(PlayerCharacter player, StateDriver driver, Playable playable, PoseInfo pose)
        {
            if (driver == null)
            {
                return;
            }

      #if UNITY_EDITOR
            if (Application.isPlaying)
            {
      #endif

            if (!driver.IsInState(player.FSM))
            {
                driver.ForceStateChangeOn(player.FSM);
            }

      #if UNITY_EDITOR
        }

        else
        {
            // In-Editor we don't want to actually change the Finite State Machine,
            // so just play the appropriate animation.
            float totalTrackTime    = (float)playable.GetTime();
            float currentTimeInClip = totalTrackTime - pose.StartTime;

            driver.SampleClip(player.FSM, currentTimeInClip);
        }
      #endif
        }
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            // The playable graph can sometimes evaluate outside of our control, due to the way the Timeline Window
            // takes control of playback, so we check if this is a manual evaluation from RecordedSessionDirector
            if (m_VideoPlayer == null || !m_VideoPlayer.isPrepared || !m_SessionDirector.IsEvaluating || m_SessionDirector.IsSyncing)
            {
                return;
            }

            var time = playable.GetTime();

            if (time >= m_VideoLength)
            {
                m_VideoPlayer.time = m_VideoLength;
                return;
            }

            var videoTime = time;

            m_VideoPlayer.externalReferenceTime = videoTime;

            if (!m_VideoPlayer.isPlaying)
            {
                m_VideoPlayer.time = videoTime;
                if (playable.GetGraph().IsPlaying())
                {
                    m_VideoPlayer.Play();
                }
            }
        }
예제 #30
0
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            var current = (float)playable.GetTime();

            // Playback or scrubbing?
            if (info.evaluationType == FrameData.EvaluationType.Playback)
            {
                // Trigger signals between the prrevious/current time.
                TriggerSignals(playable, info.output, _previousTime, current);
            }
            else
            {
                // Maximum allowable time difference for scrubbing
                const float maxDiff = 0.1f;

                // If the time is increasing and the difference is smaller
                // than maxDiff, it's being scrubbed.
                if (current - _previousTime < maxDiff)
                {
                    // Trigger the signals as usual.
                    TriggerSignals(playable, info.output, _previousTime, current);
                }
                else
                {
                    // It's jumping not scrubbed, so trigger signals laying
                    // around the current frame.
                    var t0 = Mathf.Max(0, current - maxDiff);
                    TriggerSignals(playable, info.output, t0, current);
                }
            }

            _previousTime = current;
        }