【发布时间】:2018-12-31 19:53:51
【问题描述】:
主要目标是将List中的所有动画一个一个播放完,播放第一个等待它播放完再开始下一个。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayAnimations : MonoBehaviour
{
public Animator animator;
private List<AnimationClip> clips = new List<AnimationClip>();
// Start is called before the first frame update
void Start()
{
foreach (AnimationClip ac in animator.runtimeAnimatorController.animationClips)
{
StartCoroutine(PlayAll(ac.name, ac.length));
}
}
public IEnumerator PlayAll(string stateName, float length)
{
animator.Play(stateName);
yield return new WaitForSeconds(length);
}
// Update is called once per frame
void Update()
{
}
}
但它只播放一个动画剪辑,并且动画控制器中有两个。为什么 ?
它只播放第二个具有 StateMachine 默认状态的第一个不播放。
【问题讨论】: