//动画名称
public const string ANIM_NAME = "Take 001";
//模型对象
private GameObject obj = null;
//进度条
public float hSliderValue = 0.0f;
public float animLegth = 0.0f;
void Start ()
{
//得到模型动画
obj = GameObject.Find("man");
//得到动画播放长度
animLegth = obj.animation.animation[ANIM_NAME].length;
}
void OnGUI()
{
//显示信息
string show = "CurrentAnimationLength"+hSliderValue.ToString() + "(s)" + "/" +animLegth.ToString() + "(s)";
GUILayout.Label(show);
//计算拖动条拖动数值
hSliderValue = GUILayout.HorizontalSlider(hSliderValue,0.0f,5.0f,GUILayout.Width(200));
//绘制动画帧
PlaysilderAnimation(obj,hSliderValue);
}
public void PlaysilderAnimation(GameObject manObject,float times)
{
//播放动画
//IsPlaying要用I是大写的不要用isPlaying这个 一定要看清
if(!manObject.animation.IsPlaying)
{
// manObject.animation.Play(ANIM_NAME);
manObject.animation.Play(ANIM_NAME);
}
//设置动画时间
manObject.animation.animation[ANIM_NAME].time = times;
}