Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 612 Bytes

File metadata and controls

34 lines (25 loc) · 612 Bytes

UNT0009 Missing static constructor with InitializeOnLoad

Provide a static constructor when applying the InitializeOnLoad attribute to a class. This will call it when the editor launches.

Examples of patterns that are flagged by this analyzer

using UnityEngine;
using UnityEditor;

[InitializeOnLoad]
class Camera : MonoBehaviour
{
}

Solution

Add static constructor:

using UnityEngine;
using UnityEditor;

[InitializeOnLoad]
class Camera : MonoBehaviour
{
    static Camera()
    {
    }
}

A code fix is offered for this diagnostic to automatically apply this change.