Version: 2017.1
public AnimationState PlayQueued (string animation, QueueMode queue= QueueMode.CompleteOthers, PlayMode mode= PlayMode.StopSameLayer);

描述

在先前的动画播放完毕后再播放动画。

例如,您可能会按指定的序列依次播放每个动画。

该动画状态在播放前会自我复制,因此您可以在相同动画之间淡入淡出。 这可用于覆盖两个相同动画。例如,您可能有一个挥剑的动画。 玩家在将剑挥来挥去后快速猛砍两下。 您可以将该动画倒回,从头开始播放,但之后您会看到动画有跳帧现象。

The following queue modes are available:
If queue is QueueMode.CompleteOthers this animation will only start once all other animations have stopped playing.
If queue is QueueMode.PlayNow this animation will start playing immediately on a duplicated animation state.

动画播放完毕后,将自动执行自我清理。在该动画播放完成后使用复制动画状态将导致异常。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Animation anim; void Start() { anim = GetComponent<Animation>(); } void Update() { if (Input.GetButtonDown("Fire1")) anim.PlayQueued("shoot", QueueMode.PlayNow); } }