在后续 time 秒的时间段内,使名称为 animation 的动画淡入,使其他动画淡出。
如果模式为 PlayMode.StopSameLayer,在 animation 淡入时,与 animation 同层中的动画将淡出。
如果模式为 PlayMode.StopAll,在 animation 淡入时,所有动画都将淡出。
如果未将该动画设置为循环,则该动画在播放后将停止并倒回。
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Animation anim; void Start() { anim = GetComponent<Animation>(); } void Update() { if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1F) anim.CrossFade("Run"); else anim.CrossFade("Idle"); } }