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

using UnityEngine;
using System.Collections;

public class AnimationsCount : MonoBehaviour {

Animation anim;
string[] animName;
// Use this for initialization
void Start () {
anim = this.gameObject.GetComponent();
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()
{

}
}

转载于:https://www.cnblogs.com/ZeroMurder/p/5829176.html

你可能感兴趣的:(unity中遍历动画得到动画名字和动画数量)