Animation最常用的

来源:互联网 发布:华为面试题 2017 java 编辑:程序博客网 时间:2024/05/18 10:41
using System.Collections;using System.Collections.Generic;using UnityEngine;//animation  必须用legacypublic class Anim : MonoBehaviour{    public Animation anim;    public AnimationClip clip;    void Start()    {        anim = GetComponent<Animation>();        foreach (AnimationState state in anim)//所有的动画事件速度        {            state.speed = 0.5F;        }        anim["animClip"].speed = 0.5f;//其中的一个动画速度        anim.Play("animClip");        anim.Stop("animClip");        anim.CrossFade("animClip");//和play类似,例子往前跑,然后往左走。动画转换的时候,play直接结束跑,播放往左走;CrossFade由跑到走会有一个过度    }    void Update()    {        if (!anim.isPlaying)        {            print("The end of the animation");        }    }    void animState()    {        print("动画播放到某帧  可以添加执行某函数,需要在动画那里添加个事件");    }}