List<Animator> animators = obj.GetComponentsInChildren<Animator>().ToList();
if (animators.Count > 0)
{
int aniCount = animators.Count;
for (int i = 0; i < aniCount; i++)
{
for (int j = 0; j < animators[i].runtimeAnimatorController.animationClips.Length; j++)
{
AnimationClip clip = animators[i].runtimeAnimatorController.animationClips[j];
if (clip != null)
{
foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
{
ObjectReferenceKeyframe[] keyFrames = AnimationUtility.GetObjectReferenceCurve(clip, binding);
if (keyFrames != null && keyFrames.Length > 0)
{
int keyLength = keyFrames.Length;
for (int k = 0; k < keyLength; k++)
{
if (keyFrames[k].value is Sprite)
{
Sprite sprite = (Sprite)keyFrames[k].value;
string path = AssetDatabase.GetAssetPath(sprite);
UIPrefabClass prefabClass = new UIPrefabClass(sprite, null, path);
if (!isContainSprite(sprites, prefabClass))
{
sprites.Add(prefabClass);
}
}
}
}
}
}
}
}
}
Unity Editor获取Animator帧动画中的所有图片
最新推荐文章于 2024-08-30 06:00:00 发布