首页 > 代码库 > unity中遍历动画得到动画名字和动画数量

unity中遍历动画得到动画名字和动画数量

using UnityEngine;
using System.Collections;

public class AnimationsCount : MonoBehaviour {

Animation anim;
string[] animName;
// Use this for initialization
void Start () {
anim = this.gameObject.GetComponent<Animation>();
int a = anim.GetClipCount();
Debug.Log("----------------------------------动画的个数一共是:" + a);
int i = 0;
animName = new string[anim.GetClipCount()];
//Debug.Log("---这些动画的名字是:" + animName);
foreach (AnimationState state in anim)
{
animName[i++] = state.name;
Debug.Log(animName[i - 1]);
}

}

void GetAnimCountAndNum()
{

}
}

unity中遍历动画得到动画名字和动画数量