So führen Sie Code ohne GameObject Unity aus
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
// Make sure you remove the "MonoBehaviour"
Bonus
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
// Make sure you remove the "MonoBehaviour"