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()
{

}
}

posted @ 2016-09-01 11:34  Fei非非  阅读(1929)  评论(0编辑  收藏  举报