先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace RootMotion
|
|
{
|
|
public class AnimationModifierStack : MonoBehaviour
|
|
{
|
|
public AnimationModifier[] modifiers = new AnimationModifier[0];
|
|
|
|
private Animator animator;
|
|
private Baker baker;
|
|
|
|
private void Start()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
baker = GetComponent<Baker>();
|
|
baker.OnStartClip += OnBakerStartClip;
|
|
baker.OnUpdateClip += OnBakerUpdateClip;
|
|
|
|
foreach (AnimationModifier m in modifiers)
|
|
{
|
|
m.OnInitiate(baker, animator);
|
|
}
|
|
}
|
|
|
|
private void OnBakerStartClip(AnimationClip clip, float normalizedTime)
|
|
{
|
|
foreach (AnimationModifier m in modifiers)
|
|
{
|
|
m.OnStartClip(clip);
|
|
}
|
|
}
|
|
|
|
private void OnBakerUpdateClip(AnimationClip clip, float normalizedTime)
|
|
{
|
|
foreach (AnimationModifier m in modifiers)
|
|
{
|
|
if (!m.enabled) continue;
|
|
m.OnBakerUpdate(normalizedTime);
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!animator.enabled && !baker.isBaking) return;
|
|
if (baker.isBaking && baker.mode == Baker.Mode.AnimationClips) return;
|
|
if (animator.runtimeAnimatorController == null) return;
|
|
|
|
AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
|
|
float n = info.normalizedTime;
|
|
|
|
foreach (AnimationModifier m in modifiers)
|
|
{
|
|
if (!m.enabled) continue;
|
|
m.OnBakerUpdate(n);
|
|
}
|
|
}
|
|
}
|
|
}
|