Unity 动画帧采样
2024/01
08
10:01
美术可以制作一个复杂的Animation,程序只需要调用一下SetAniProgress,指定进度条就行了
using UnityEngine;
public class PlayFrame : MonoBehaviour
{
public float rate = 0.35f;
public string clipName = "Ani1";
public static int SetAniProgress(GameObject obj, string clipName, float progress)
{
if (obj == null)
{
return -1;
}
var aniObj = obj.GetComponent<Animation>();
if (aniObj == null)
{
return -2;
}
var clip = aniObj.GetClip(clipName);
if (clip == null)
{
return -3;
}
var time = clip.length * progress;
clip.SampleAnimation(obj, time);
return 0;
}
void Update()
{
SetAniProgress(this.gameObject, clipName, rate);
}
}
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: Unity 动画帧采样
Post Link: Unity 动画帧采样