动画系统 - Animation的基本属性 代码示例
public class AniceshiDemo : MonoBehaviour {
Animation ani; //声明Animatio 类型
// Use this for initialization
void Start () {
ani = GetComponent<Animation>();
Debug.Log("当前播放的动画剪辑是:" + ani.clip);
Debug.Log("是否有任意动画在播放:" + ani.isPlaying);
Debug.Log("返回指定名称的动画状态:" + ani["walk"]);
Debug.Log("获取该动画的剪辑数量:" + ani.GetClipCount());
Debug.Log("是否有名为()的在播放:" + ani.IsPlaying("walk"));
AnimationState anistate = ani["walk"]; //通过this[name]的形式,获取一个 动画状态
Debug.Log(anistate.name); //该剪辑的名字和长度
Debug.Log(anistate.length);
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Q))
{
ani.Play("walk"); //播放walk动作
}
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("成功移除剪辑");
ani.RemoveClip("walk"); //移除某个剪辑 (参数可以是String类型,或者AnimationClip类型)
}
if (Input.GetKeyDown(KeyCode.S))
{
ani.Rewind("walk"); //倒回 (参数可以是String类型,或者不传参数)
}
}
}
作者:Czhenya 发表于2017/8/21 16:22:29 原文链接
阅读:38 评论:0 查看评论