public static void Initialize() { if (!initialized) { if (!Application.isPlaying) { return; } instance = new GameObject("ThreadResolver").AddComponent <MainThreadResolver>(); initialized = true; DontDestroyOnLoad(instance.gameObject); } }
private void Awake() { if (instance == null) { instance = this; initialized = true; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(this); } }