本文整理汇总了C#中Animator.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.Update方法的具体用法?C# Animator.Update怎么用?C# Animator.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animator
的用法示例。
在下文中一共展示了Animator.Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play
public static bool Play(Animator anim, string name, float speed = 1.0f, float time = 0.0f)
{
if (!anim)
{
return false;
}
// Enable animator
if (!anim.enabled)
{
anim.enabled = true;
}
anim.speed = speed;
anim.Play(name, -1, time);
anim.Update(0.0f); // Update for the latest state
return true;
}
示例2: TestAnis
void TestAnis()
{
ani = sellast.GetComponentInChildren<Animator>();
Animation aniold = sellast.GetComponentInChildren<Animation>();
SkinnedMeshRenderer[] skins = sellast.GetComponentsInChildren<SkinnedMeshRenderer>();
GUILayout.Label("Find Ani:" + (ani != null) + ", skinmesh count=" + skins.Length);
if (ani == null)
{
GUILayout.Label("Need Animator Component");
if(aniold!=null)
{
GUILayout.Label("You have a old Animation Component.But we only support Animator.");
}
return;
}
List<AnimationClip> anis = new List<AnimationClip>();
var ac = ani.runtimeAnimatorController as UnityEditorInternal.AnimatorController;
FindAllAniInControl(ac, anis);
foreach (var a in anis)
{
if (GUILayout.Button("haveani:" + a.name, GUILayout.MinWidth(1)))
{
_selectClip = a;
anistart = 0;
aniend = a.length;
bPlay = false;
//ani.Play(a.name, 0, 0);
}
}
if(_selectClip)
{
var an = ani.GetCurrentAnimatorStateInfo(0);
anistart = GUILayout.HorizontalSlider(anistart, 0, _selectClip.length, GUILayout.MinHeight(1));
if (anistart >= aniend) anistart = aniend;
aniend = GUILayout.HorizontalSlider(aniend, 0, _selectClip.length, GUILayout.MinHeight(1));
if (aniend <= anistart) aniend = anistart;
aninow = GUILayout.HorizontalSlider(aninow, anistart, aniend, GUILayout.MinHeight(1));
if (!bPlay)
{
ani.Play(_selectClip.name, 0, 0);
ani.speed = 1.0f;
ani.Update(aninow);
}
bPlay = GUILayout.Toggle(bPlay, "Play", GUILayout.MaxWidth(100));
}
}
示例3: SyncAnimation
private void SyncAnimation(Animator animator, float normalizedTime)
{
animator.Play(0, -1, normalizedTime);
animator.Update(Time.deltaTime);
}