UNT0020 MenuItem attribute used on non-static method
January 14, 2021 ยท View on GitHub
The MenuItem attribute turns any static function into a menu command. Only static functions can use the MenuItem attribute.
Examples of patterns that are flagged by this analyzer
using UnityEngine;
using UnityEditor;
class Camera : MonoBehaviour
{
[MenuItem(""Name"")]
private void Menu1()
{
}
}
Solution
Fix method signature:
using UnityEngine;
using UnityEditor;
class Camera : MonoBehaviour
{
[MenuItem(""Name"")]
private static void Menu1()
{
}
}
A code fix is offered for this diagnostic to automatically apply this change.