public static void EnsureHelper() { lock (syncRoot) { if ((object)null == instance) { instance = UnityEngine.Object.FindObjectOfType(typeof(UnityThreadHelper)) as UnityThreadHelper; if ((object)null == instance) { GameObject gameObject = new GameObject("[UnityThreadHelper]"); gameObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable; instance = gameObject.AddComponent <UnityThreadHelper>(); instance.EnsureHelperInstance(); } } } }
private void OnDestroy() { foreach (ThreadBase registeredThread in registeredThreads) { registeredThread.Dispose(); } if (dispatcher != null) { dispatcher.Dispose(); } dispatcher = null; if (taskDistributor != null) { taskDistributor.Dispose(); } taskDistributor = null; if (instance == this) { instance = null; } }