本文整理匯總了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);
}