public void OnDisable() { if (_instance == this) { _instance = null; } }
public static void InitUnityThread(bool visible = false) { if (_instance != null) { return; } if (!Application.isPlaying) { return; } var obj = new GameObject("MainThreadExecuter"); if (!visible) { obj.hideFlags = HideFlags.HideAndDontSave; } DontDestroyOnLoad(obj); _instance = obj.AddComponent <UnityThread>(); }