-
Notifications
You must be signed in to change notification settings - Fork 135
Redundant InitializeOnLoad attribute
Matt Ellis edited this page Mar 27, 2018
·
2 revisions
If a class is marked with the [InitializeOnLoad]
attribute, then Unity will ensure that the static constructor is called as the Unity editor starts, or when the run button is pressed.
This inspection will mark the [InitializeOnLoad]
attribute usage as redundant if the class doesn't contain a static constructor. It will also add two Alt+Enter quick fixes, one to remove the redundant attribute and another to create the static constructor in the class.
For more details, see the Unity documentation for InitializeOnLoadAttribute
and Running Editor Script Code on Launch.