private IEnumerator Capture () { if(videoframe < framesToCapture) { string name =System.String.Format("{0}/{1:D04} sprite.png", realFolder, videoframe );//Time.frameCount yield return new WaitForEndOfFrame(); int width = Screen.width; int height = Screen.height; Texture2D texb = new Texture2D(width, height, TextureFormat.RGB24, false); texb.ReadPixels(new Rect(0, 0, width, height), 0, 0); texb.Apply(); yield return 0; yield return new WaitForEndOfFrame(); Texture2D texw = new Texture2D(width, height, TextureFormat.RGB24, false); texw.ReadPixels(new Rect(0, 0, width, height), 0, 0); texw.Apply(); Texture2D outputtex = new Texture2D(width, height, TextureFormat.ARGB32, false); for (int y = 0; y < outputtex.height; ++y) { for (int x = 0; x < outputtex.width; ++x) { var alpha = texw.GetPixel(x, y).r - texb.GetPixel(x, y).r; alpha = 1.0f - alpha; Color color = Color.clear; if(alpha != 0) { color = texb.GetPixel(x, y) / alpha; } color.a = alpha; outputtex.SetPixel(x, y, color); } } Texture2D tex=outputtex.Trim(padding); textures.Add(tex); tex.SaveTexture(name); Destroy(texb); Destroy(texw); videoframe++; } else { EditorApplication.isPlaying=false; done=true; } }