-
public class Crystal : MonoBehaviour {
-
-
private Animator anim;
-
// Use this for initialization
-
void Start () {
-
-
//play动画
-
anim = gameObject.GetComponent<Animator>();
-
//anim.SetInteger("MyPlay", 1);
-
-
}
-
-
// Update is called once per frame
-
void Update () {
-
transform.Rotate(0, 0, 0.2f);
-
-
-
AnimatorStateInfo animatorInfo = anim.GetCurrentAnimatorStateInfo (0);//必须放在update里
-
if ((animatorInfo.normalizedTime > 1.0f) && (animatorInfo.IsName("MyPlay")))//normalizedTime: 范围0 -- 1, 0是动作开始,1是动作结束
-
{
-
anim.SetInteger("MyPlay", 0);//播放完成后回到待机动画
-
}
-
-
}
-
}