private static CoroutineHostInstance InstantiateCoroutineHost() { GameObject coroutineHost = new GameObject("Coroutine Host"); CoroutineHostInstance chi = coroutineHost.AddComponent <CoroutineHostInstance>(); GameObject.DontDestroyOnLoad(coroutineHost); return(chi); }
/// <summary> /// Because we can't instantiate game objects from other thread, call this to pre-instantiate the host in the main thread first. /// </summary> public static void PrepareCrossThread() { crossThreadHost = InstantiateCoroutineHost(); }