本文整理汇总了C#中UnityEngine.Animator.GetAnimatorTransitionInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.GetAnimatorTransitionInfo方法的具体用法?C# Animator.GetAnimatorTransitionInfo怎么用?C# Animator.GetAnimatorTransitionInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animator
的用法示例。
在下文中一共展示了Animator.GetAnimatorTransitionInfo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStateMove
public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
var normTime = animator.GetAnimatorTransitionInfo(layerIndex).normalizedTime;
var go = animator.gameObject;
if (normTime > 0 && canSetVolume /*&& normTime < 1*/)
{
int count = Parameters.ParameterList.Count;
if (!canSetVolume)
{
}
canSetVolume = true;
for (int i = 0; i < count; i++)
{
var elem = Parameters.ParameterList[i];
//if (elem.StartVolume != elem.Target)
{
float lerp = Mathf.Lerp(elem.StartVolume, elem.Target, normTime);
//Debug.Log(name + " " + lerp + " " + elem.StartVolume + " " + elem.Target);
InAudio.SetVolumeForNode(go, elem.Node, lerp);
}
}
}
//Debug.Log(animator.GetAnimatorTransitionInfo(layerIndex).normalizedTime);
}
示例2: UpdateStateProgress
// Updates the progress counter of this animation state.
void UpdateStateProgress (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);
if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
m_progress = info.normalizedTime; // Set progress of the animation to the time taken so far.
} else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
m_progress = (1 - info.normalizedTime); // Set the final progress of the animation.
}
}
示例3: UpdateStatePower
void UpdateStatePower(Animator animator, AnimatorStateInfo stateInfo, int layerIndex){
AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);
if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
_power = info.normalizedTime;
}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
_power = (1-info.normalizedTime);
}
}
示例4: OnStateUpdate
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
AnimatorTransitionInfo info = animator.GetAnimatorTransitionInfo (layerIndex);
if (animator.GetNextAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()) { //Entering the state
_power = info.normalizedTime;
}else if(animator.GetCurrentAnimatorStateInfo(layerIndex).GetHashCode() == stateInfo.GetHashCode()){ //Exiting the state
_power = (1-info.normalizedTime);
}
if (_power > 0.98f) {
animator.SetBool ("Holstered", true);
animator.SetBool ("Holster", false);
}
}
示例5: OnStateEnter
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log(1 + "-" + stateInfo.fullPathHash + "-" + Animator.StringToHash("Base.Idle.idle1")+"-"+ stateInfo.length + "-" + stateInfo.normalizedTime + "-" + (stateInfo.normalizedTime - prev));
prev = stateInfo.normalizedTime;
// animationManager.initState(animator, stateInfo);
AnimationEvent ae = new AnimationEvent();
ae.functionName = "animationEvent";
AnimatorTransitionInfo ati = animator.GetAnimatorTransitionInfo(layerIndex);
AnimatorClipInfo aci = animator.GetCurrentAnimatorClipInfo(layerIndex)[0];
aci.clip.AddEvent(ae);
Debug.Log( "进入:"+ aci.clip.name +"-"+ stateInfo.fullPathHash + "-" + stateInfo.length + "-" + stateInfo.normalizedTime + "-" + (stateInfo.normalizedTime - prev));
//animator.SetInteger("idle",Random.Range(1, 3));
//AnimationAction animationAction = AnimationManager.getAnimationAction(animator);
}
示例6: OnStateUpdate
// OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Break();
AnimatorTransitionInfo ati = animator.GetAnimatorTransitionInfo(layerIndex);
AnimatorClipInfo []acis = animator.GetCurrentAnimatorClipInfo(layerIndex);
string acit = "";
foreach (AnimatorClipInfo aci in acis){
acit += "["+aci.weight + ":" + aci.clip.name+"],";
}
//Debug.Log(2 + "-[" + ati.normalizedTime + "]-["+animator.GetCurrentAnimatorClipInfo(layerIndex)[0].clip.name+ "]-["+stateInfo.normalizedTime+"]-"+ (stateInfo.normalizedTime-prev));
prev = stateInfo.normalizedTime;
Debug.Log("update:" + stateInfo.fullPathHash+"-"+acit+stateInfo.normalizedTime);
if (stateInfo.normalizedTime>0.8f)
{
// Debug.Log(stateInfo.fullPathHash);
//animator.SetInteger("Attack", 0);
//Debug.Break();
}
}
示例7: Start
void Start()
{
controller = GetComponent<CharacterController>();
cam = Camera.main;
anim = GetComponentInChildren<Animator>();
armsTransitionInfo = anim.GetAnimatorTransitionInfo(1);
EquipGun(0);
}
示例8: CheckForAnimatorStateChanges
public void CheckForAnimatorStateChanges (Animator animator) {
for (int layer = 0; layer < LayerCount; layer++) {
LayerStatuses [layer].State.Current = animator.GetCurrentAnimatorStateInfo (layer).nameHash;
if (animator.IsInTransition (layer)) {
LayerStatuses [layer].Transition.Current = animator.GetAnimatorTransitionInfo (layer).nameHash;
} else {
LayerStatuses [layer].Transition.Current = 0;
}
}
if (StateHandlers != null && StateHandlers.Count > 0) {
var enumerator = StateHandlers.GetEnumerator();
try {
while (enumerator.MoveNext()) {
var pair = enumerator.Current;
var handler = pair.Value;
handler.Perform (LayerStatuses, StateInfos);
}
}
finally {
enumerator.Dispose();
}
}
if (TransitionHandlers != null && TransitionHandlers.Count > 0) {
var enumerator = TransitionHandlers.GetEnumerator();
try {
while (enumerator.MoveNext()) {
var pair = enumerator.Current;
var handler = pair.Value;
handler.Perform (LayerStatuses, TransitionInfos);
}
}
finally {
enumerator.Dispose();
}
}
}