本文整理匯總了C#中Animation.Sample方法的典型用法代碼示例。如果您正苦於以下問題:C# Animation.Sample方法的具體用法?C# Animation.Sample怎麽用?C# Animation.Sample使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Animation
的用法示例。
在下文中一共展示了Animation.Sample方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PlayAnimation
/// <summary>
/// 播放動畫片段
/// </summary>
/// <param name="anim"></param>
/// <param name="name"></param>
/// <param name="dir"></param>
/// <returns></returns>
public static AnimationState PlayAnimation(Animation anim, string name, AnimationOrTween.Direction dir)
{
var state = anim[name];
if (state)
{
float speed = Mathf.Abs(state.speed);
state.speed = speed * (int)dir;
if (dir == AnimationOrTween.Direction.Reverse && state.time == 0f) state.time = state.length;
else if (dir == AnimationOrTween.Direction.Forward && state.time == state.length) state.time = 0f;
//Debug.Log(string.Format(" speed {0},dir ={1},time = {2},length={3}",state.speed,dir,state.time,state.length));
anim.Play(name);
anim.Sample();
}
return state;
}