代码检查:相同的快捷键已为其他菜单项定义。
此检查会报告 MenuItem 特性中重复的快捷键定义。 如果多个菜单项使用相同的快捷键,Unity 可能会出现不可预测的行为,并且该快捷键可能会触发错误的命令或变得含糊。
示例
在此示例中, RunAction 和 RunOtherAction 都使用了相同的快捷键 %g。
using UnityEditor;
public class Example
{
[MenuItem("Tools/Run Action %g")]
static void RunAction()
{
}
[MenuItem("Tools/Run Other Action %g")]
static void RunOtherAction()
{
}
}
using UnityEditor;
public class Example
{
[MenuItem("Tools/Run Action %g")]
static void RunAction()
{
}
[MenuItem("Tools/Run Other Action %h")]
static void RunOtherAction()
{
}
}
快速修复
此检查不提供专用快速修复。 请通过更改或移除其中一个快捷键定义手动解决冲突。
2026年 5月 8日