代码检查:项目中没有具有相同名称的动画状态。
此检查会报告传递给 Animator.Play(...) 的动画状态名称在项目中没有匹配的已知动画状态。
只有在启用资源索引并且 Unity 资源为文本格式可用时,检查才能正常工作,因为需要从项目资源中读取动画状态名称。
示例
在此示例中,使用了 "Attack" 状态名称,但在已索引的项目资源中不存在该名称。
using UnityEngine;
public class Example : MonoBehaviour
{
public Animator animator;
private void Start()
{
// Reported: "Attack" state not found in animator assets
animator.Play("Attack");
}
}
using UnityEngine;
public class Example : MonoBehaviour
{
public Animator animator;
private void Start()
{
// Use an animator state that exists in the project
animator.Play("Idle");
}
}
快速修复
此检查不提供专用快速修复。 请通过使用现有的动画状态名称手动修复。
2026年 5月 8日