本文整理汇总了C#中UnityEngine.Animator.StartRecording方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.StartRecording方法的具体用法?C# Animator.StartRecording怎么用?C# Animator.StartRecording使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animator
的用法示例。
在下文中一共展示了Animator.StartRecording方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStateUpdate
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
timeSinceCapture += Time.deltaTime;
if (this._BehaviourState == AnimationBehaviourState.INITIAL_POSE)//Testear si esto funciona en este behaviour.
{
if (!animator.IsInTransition(0))
animator.speed = 0;
return;
}
if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS && timeSinceCapture > INTERVAL)
{
timeSinceCapture = timeSinceCapture - INTERVAL;
/*
if (exerciseDataGenerator == null)
exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
if (this.exerciseDataGenerator != null)
this.exerciseDataGenerator.CaptureData();*/
}
float DELTA = 0.05f;
DateTime temp = DateTime.Now;
if (_BehaviourState != AnimationBehaviourState.STOPPED && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
{
if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
{
OnRepetitionReallyStart();
BeginRep = true;
}
if (stayInPoseState == StayInPoseState.GoingTo && stateInfo.normalizedTime + DELTA >= 1)
{
animator.speed = 0;
startHoldTime = Time.time;
stayInPoseState = StayInPoseState.HoldingOn;
//Esperar
}
//Si ya pasó el tiempo en el ángulo máximo
else if(stayInPoseState == StayInPoseState.HoldingOn && Time.time - startHoldTime >= _RealParams.SecondsInPose)
{
animator.StartRecording(0);
animator.speed = -this._RealParams.BackwardSpeed;
animator.StopRecording();
stayInPoseState = StayInPoseState.Leaving;
}
else if (stayInPoseState == StayInPoseState.Leaving && stateInfo.normalizedTime - DELTA <= 0 && haCambiadoDeEstado)
{
BeginRep = false;
animator.speed = 0;
stayInPoseState = StayInPoseState.Resting;
startRestTime = Time.time;
if (((!this.IsWeb) && (!this.IsInInstruction)) && _BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && (!IsInterleaved || (IsInterleaved && limb == Limb.Right)))
this.PauseAnimation();
if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
{
haCambiadoDeEstado = false;
animator.SetTrigger("ChangeLimb");
}
OnRepetitionEnd();
if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
this.Stop();
}
else if (stayInPoseState == StayInPoseState.Resting && Time.time - startRestTime>= _realParams.SecondsBetweenRepetitions)
{
this.animator.speed = this._realParams.ForwardSpeed;
stayInPoseState = StayInPoseState.GoingTo;
}
}
}
示例2: OnStateUpdate
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
clockBehaviour.Update();
if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
{
if (!animator.IsInTransition(0))
animator.speed = 0;
return;
}
#region Interpolate
//Si no estamos en estado Stopped
//Y estamos preparados para hacer Lerp
//Y el tiempo que ha transcurrido de la ultima rep es mayor al tiempo de pause entre repeticiones. O no ha habido última rep.
if (_BehaviourState != AnimationBehaviourState.STOPPED && ReadyToLerp
&& (endRepTime == null || new TimeSpan(0, 0, (int)_currentParams.SecondsBetweenRepetitions) <= DateTime.Now - endRepTime))
{
if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
{
OnRepetitionReallyStart();
BeginRep = true;
}
//if(_LerpBehaviourState == LerpBehaviourState.STOPPED)
float timeSinceStarted = Time.time - timeStartedLerping;
float percentageComplete = 0f;
/*
switch (_currentLerpState)
{
case LerpState.Forward:
percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
Debug.Log("1 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime );
break;
case LerpState.Stopped:
if (_lastLerpState == LerpState.Forward)
{
percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
Debug.Log("2 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
}
//De ser true, indica que termino una repeticion
else if (_lastLerpState == LerpState.Backward)
{
percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
Debug.Log("3 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
}
break;
case LerpState.Backward:
percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
Debug.Log("4 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
break;
}*/
percentageComplete = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
//float normalizedSpeed;
//if (percentageComplete < 0.5)
// normalizedSpeed = timeSinceStarted/timeTakenDuringForwardLerp * 4;
//else
// normalizedSpeed = 4f- timeSinceStarted / timeTakenDuringForwardLerp * 4;
//Aplico el suavizado "Smotherstep"
//percentageComplete = percentageComplete * percentageComplete * (3f - 2f * percentageComplete);
//float percentageSmotherstep = timeSinceStarted * timeSinceStarted * timeSinceStarted * (timeSinceStarted * (6f * timeSinceStarted - 15f) + 10f);
float sp = endPosition + startPosition;
if (!holdingPose)
{
animator.StartRecording(0);
animator.speed = sp;// Mathf.Lerp(startPosition, endPosition, normalizedSpeed);
//Debug.Log("% "+ percentageComplete + "normalized speed " + normalizedSpeed + " speed " + animator.speed);
animator.StopRecording();
}
float DELTA = 0.03f;
if ((animator.speed > 0 && percentageComplete >= 1.0f - DELTA) ||
(animator.speed < 0 && percentageComplete <= 0f + DELTA))
{
Debug.Log("int end " + percentageComplete);
InterpolationEnd();
}
}
else if(this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
{
animator.speed = 0;
}
if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
{
timeSinceCapture += Time.deltaTime;
if (timeSinceCapture > INTERVAL)
{
//.........这里部分代码省略.........
示例3: OnStateUpdate
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
clockBehaviour.Update();
if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
{
if (!animator.IsInTransition(0))
animator.speed = 0;
return;
}
float DELTA = 0.05f;
DateTime temp = DateTime.Now;
if (this._BehaviourState != AnimationBehaviourState.STOPPED && !IsCentralNode)
{
if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
{
OnRepetitionReallyStart();
BeginRep = true;
}
if (this.CentralNode._StayInPoseState == StayInPoseState.GoingTo && stateInfo.normalizedTime - DELTA >= 1)
{
animator.speed = 0;
startHoldTime = Time.time;
clockBehaviour.executeRepetitionTime(this.CentralNode._RealParams.SecondsInPose);
this.CentralNode._StayInPoseState = StayInPoseState.HoldingOn;
}
//Si ya pasó el tiempo en el ángulo máximo
else if(this.CentralNode._StayInPoseState == StayInPoseState.HoldingOn && this.CentralNode.holdingPose)
{
this.CentralNode.holdingPose = false;
animator.StartRecording(0);
animator.speed = -this.CentralNode._RealParams.BackwardSpeed;
animator.StopRecording();
this.CentralNode._StayInPoseState = StayInPoseState.Leaving;
}
else if (this.CentralNode._StayInPoseState == StayInPoseState.Leaving &&
stateInfo.normalizedTime - DELTA <= 0)
{
BeginRep = false;
animator.speed = this.CentralNode._RealParams.ForwardSpeed;
this.CentralNode._StayInPoseState = StayInPoseState.GoingTo;
startRestTime = Time.time;
animator.SetInteger("Movement", -1);
if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
{
animator.SetTrigger("ChangeLimb");
}
if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
_BehaviourState = AnimationBehaviourState.STOPPED;
//OnRepetitionEnd();
}
}
}