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); }
public override void OnGraphStart(Playable playable) { duration = (float)playable.GetDuration(); float scrollingDuration = Mathf.Clamp(duration - holdDelay - startDelay, float.Epsilon, duration); inverseScrollingDuration = 1f / scrollingDuration; }
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; }
public override void OnBehaviourPause(Playable playable, FrameData info) { if (video == null) { return; } if (PlayingState.IsPreviewingInPlayMode || PlayingState.IsPlayingTimelineInEditor) { video.Stop(); } if (PlayingState.IsScrubbing) { var duringVideo = (playable.GetTime() / playable.GetDuration()) < 1d; if (duringVideo) { video.Pause(); } else { video.Stop(); } } if (PlayingState.IsRecording) { video.Stop(); video.frameReady -= FrameReady; isInVideoTime = false; } }
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)); } } }
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); } }
/// <summary> /// クリップ再生時の処理 /// </summary> /// <param name="playable"></param> /// <param name="info"></param> public override void OnBehaviourPlay(Playable playable, FrameData info) { // クリップの開始時間を保持 var clipStartTime = Director.time; clipEndTime = clipStartTime + playable.GetDuration(); }
// 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); }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { Plugin = playerData as Plugin4DS; if (onstart) { if (Plugin == null) { return; } double duration = playable.GetDuration() * Plugin.Framerate; double newSpeed = 1; if (firstFrame < lastFrame && firstFrame >= 0) { newSpeed = (lastFrame - firstFrame) / duration; //Debug.Log("new speed : " + newSpeed); } else { newSpeed = (Plugin.SequenceNbOfFrames - firstFrame) / duration; //Debug.Log("new speed : " + newSpeed); } Plugin.SpeedRatio = (float)newSpeed; Plugin.GotoFrame(firstFrame); Plugin.Play(true); onstart = false; } base.ProcessFrame(playable, info, playerData); }
private void Setup(Playable playable) { _started = true; _duration = (float)playable.GetDuration(); Animator = PoseAnimator.Main; Animator.UpdatePose(); SetupPoseTransition(Animator.DefaultPose); }
// Called each frame while the state is set to Play public override void PrepareFrame(Playable playable, FrameData info) { if (blurCtrl != null) { var pct = playable.GetTime() / playable.GetDuration(); blurCtrl.blurSize.value = this.blurSizeCur.Evaluate((float)pct); } }
void SyncDurationWithExternalSource(Playable playable) { if (m_TimeSource.IsValid()) { playable.SetDuration(m_TimeSource.GetDuration()); playable.SetTimeWrapMode(m_TimeSource.GetTimeWrapMode()); } }
//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; } }
//Will hide the dialogue in the last .4f seconds of the clip //so that a following piece of dialogue doesn't overlap public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (!dialogueHidden && (float)(playable.GetDuration() - playable.GetTime()) < .4f) { UIManager.Instance.HideDialogue(); dialogueHidden = true; } }
/// <summary> /// クリップの再生終了時刻へ時間を飛ばす処理 /// </summary> /// <param name="playable"></param> public void GoToClipEnd(Playable playable) { // クリップ全体の時間 var clipDuration = playable.GetDuration(); // 経過時間 var clipNowTime = playable.GetTime(); Director.time += clipDuration - clipNowTime; }
/// <summary> /// クリップ終了時に呼び出される処理 /// </summary> /// <param name="playable"></param> /// <param name="info"></param> public override void OnBehaviourPause(Playable playable, FrameData info) { // まだループするべきなら時間をクリップの開始時刻に戻す if (IsLooping) { Director.time -= playable.GetDuration(); return; } }
public override void OnGraphStart(Playable playable) { Duration = playable.GetDuration(); if (Mathf.Approximately((float)Duration, 0f)) { throw new UnityException("A TransformTween cannot have a duration of zero."); } inverseDuration = 1f / (float)Duration; }
public override void OnPlayableCreate(Playable playable) { var duration = playable.GetDuration(); if (Mathf.Approximately((float)duration, 0)) { throw new UnityException("A Clip Cannot have a duration of zero"); } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { duration = (float)playable.GetDuration(); passedTime = (float)playable.GetTime(); float t = duration - passedTime; EvaluteAtTime(t); }
private bool fadeOutRequired(Playable playable) { // Check whether we are currently within a fade out or blend out segment. float timeLeft = (float)(playable.GetDuration() - playable.GetTime()); float remainingBlendOutDuration = blendOutDuration - timeLeft; float remainingEaseOutDuration = easeOutDuration - timeLeft; return(remainingBlendOutDuration >= 0.0f || remainingEaseOutDuration >= 0.0f); }
/// <summary> /// This method is called during the PrepareFrame phase of the PlayableGraph. /// </summary> /// <remarks> /// Called once before processing starts. /// </remarks> /// <param name="playable">The reference to the playable associated with this PlayableBehaviour.</param> /// <param name="info">Playable context information such as weight, evaluationType, and so on.</param> public override void PrepareFrame(Playable playable, FrameData info) { // Never trigger on scrub if (info.evaluationType == FrameData.EvaluationType.Evaluate) { return; } SyncDurationWithExternalSource(playable); SortNotifications(); var currentTime = playable.GetTime(); // Fire notifications from previousTime till the end if (info.timeLooped) { var duration = playable.GetDuration(); TriggerNotificationsInRange(m_PreviousTime, duration, info, playable, true); var dx = playable.GetDuration() - m_PreviousTime; var nFullTimelines = (int)((info.deltaTime * info.effectiveSpeed - dx) / playable.GetDuration()); for (var i = 0; i < nFullTimelines; i++) { TriggerNotificationsInRange(0, duration, info, playable, false); } TriggerNotificationsInRange(0, currentTime, info, playable, false); } else { var pt = playable.GetTime(); TriggerNotificationsInRange(m_PreviousTime, pt, info, playable, true); } for (var i = 0; i < m_Notifications.Count; ++i) { var e = m_Notifications[i]; if (e.notificationFired && CanRestoreNotification(e, info, currentTime, m_PreviousTime)) { Restore_internal(ref e); m_Notifications[i] = e; } } m_PreviousTime = playable.GetTime(); }
// Performs blend of position and rotation of all clips connected to a track mixer // The result is applied to the track binding's (playerData) transform. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { Transform trackBinding = playerData as Transform; if (trackBinding == null) { return; } // Get the initial position and rotation of the track binding, only when ProcessFrame is first called InitializeIfNecessary(trackBinding); Vector3 accumPosition = Vector3.zero; Quaternion accumRotation = QuaternionUtils.zero; float totalPositionWeight = 0.0f; float totalRotationWeight = 0.0f; // Iterate on all mixer's inputs (ie each clip on the track) int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight <= 0) { continue; } Playable input = playable.GetInput(i); float normalizedInputTime = (float)(input.GetTime() / input.GetDuration()); // get the clip's behaviour and evaluate the progression along the curve TweenBehaviour tweenInput = GetTweenBehaviour(input); float tweenProgress = GetCurve(tweenInput).Evaluate(normalizedInputTime); // calculate the position's progression along the curve according to the input's (clip) weight if (tweenInput.shouldTweenPosition) { totalPositionWeight += inputWeight; accumPosition += TweenPosition(tweenInput, tweenProgress, inputWeight); } // calculate the rotation's progression along the curve according to the input's (clip) weight if (tweenInput.shouldTweenRotation) { totalRotationWeight += inputWeight; accumRotation = TweenRotation(tweenInput, accumRotation, tweenProgress, inputWeight); } } // Apply the final position and rotation values in the track binding trackBinding.position = accumPosition + m_InitialPosition * (1.0f - totalPositionWeight); trackBinding.rotation = accumRotation.Blend(m_InitialRotation, 1.0f - totalRotationWeight); trackBinding.rotation.Normalize(); }
public float GetStatePlayableDuration(int index) { Playable playable = m_States[index].playable; if (!playable.IsValid()) { return(0f); } return((float)playable.GetDuration()); }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { var target = playerData as Transform; if (target == null) { return; } var time = (float)playable.GetTime(); var normalizedTime = time / (float)playable.GetDuration(); // Calculate amplitude. Break if it's nearly zero. var amp = info.weight * amplitude * envelope.Evaluate(normalizedTime); if (Mathf.Approximately(amp, 0)) { return; } // Noise variables. var hash = new XXHash(randomSeed); var nt = time * noiseFrequency; var norm = 1 / 0.75f; // Calculate position offset. var p = position; if (noiseOctaves > 0) { var n = new Vector3( Perlin.Fbm(hash.Range(-1e3f, 1e3f, 0) + nt, noiseOctaves), Perlin.Fbm(hash.Range(-1e3f, 1e3f, 1) + nt, noiseOctaves), Perlin.Fbm(hash.Range(-1e3f, 1e3f, 2) + nt, noiseOctaves) ); p = Vector3.Scale(p, n) * norm; } target.localPosition += p * amp; // Calculate rotation offset. var r = rotation; if (noiseOctaves > 0) { var n = new Vector3( Perlin.Fbm(hash.Range(-1e3f, 1e3f, 3) + nt, noiseOctaves), Perlin.Fbm(hash.Range(-1e3f, 1e3f, 4) + nt, noiseOctaves), Perlin.Fbm(hash.Range(-1e3f, 1e3f, 5) + nt, noiseOctaves) ); r = Vector3.Scale(r, n) * norm; } target.localRotation *= Quaternion.Euler(r * amp); }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { base.ProcessFrame(playable, info, playerData); Color tmpColor = color; if (FadeType == EFadeInOut.FadeIn) { tmpColor.a = 1.0f - (float)(playable.GetTime() / playable.GetDuration()); } else { tmpColor.a = (float)(playable.GetTime() / playable.GetDuration()); } tmpColor.a *= color.a; if (VRFade.Instance != null) { VRFade.Instance.SetColor(tmpColor); } }
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)); }
public override void OnBehaviourPause(Playable playable, FrameData info) { if (waitTimeline.trigger == true) { waitTimeline.trigger = false; return; } Debug.Log(waitTimeline.trigger); director.time -= playable.GetDuration(); }
public override void OnGraphStart(Playable playable) { //m_VideoPlayer = m_Theater.GetComponentInChildren<VideoPlayer>(); //m_VideoPlayer.Prepare(); duration = (float)playable.GetDuration(); inverseDuration = 1f / duration; //m_VideoPlayer = m_Theater.GetComponentInChildren<VideoPlayer>(); //m_VideoPlayer.Prepare(); }
private void checkForFadeOutImmediate(Playable playable) { if (eventTracker != null && !eventTracker.fadeoutTriggered) { if (fadeOutRequired(playable)) { float timeLeft = (float)(playable.GetDuration() - playable.GetTime()); triggerFadeOut(timeLeft); } } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { base.ProcessFrame(playable, info, playerData); float duration = (float)playable.GetDuration(); float timeNow = (float)playable.GetTime(); float deltaTime = (float)info.deltaTime; Vector3 potition = (Vector3)Path?.Update(m_Target.transform, duration, timeNow, deltaTime); //设置特效位置 //Effect?.transform.position = potition; }