private IEnumerator FillTexturesThreaded () { threadShouldBeWorking = new AutoResetEvent(false); thread = new Thread(FillTextures); thread.IsBackground = true; thread.Start(); for (int i = 0; i < links.Length; i++) { currentLink = links[i]; currentLink.AllocateTextures(); threadFinished = false; threadShouldBeWorking.Set(); while (!threadFinished) { yield return null; } currentLink.ApplyTextures(buffers); currentLink.AssignTexturesToMaterials(); } currentLink = null; threadShouldBeWorking.Set(); FinishGenerating(); }