IEnumerator ProcessRoutine() { while (index < files.Count) { var bytes = File.ReadAllBytes(files[index]); index++; texture.LoadImage(bytes); texture.Apply(); renderer.transform.localPosition = Vector3.zero; renderer.material.mainTexture = texture; var size = EMath.GetNormalizedExpandAspect(new Vector2(texture.width, texture.height)); renderer.transform.localScale = new Vector3(size.x, size.y, 1f); localScale = renderer.transform.localScale; scaleRate = 1f; isWaiting = true; while (isWaiting) { yield return(null); } if (!isAllow) { continue; } captureCamera.Render(); yield return(null); TextureUtils.RenderTexture2Texture2D(rt, resultTexture); var resultBytes = resultTexture.EncodeToJPG(); var c = count; if (dictionary.ContainsKey(index)) { c = dictionary[index]; } else { count++; c = count; dictionary.Add(index, c); } var path = Path.Combine(saveDirectory, (offsetIndex + c) + ".jpg"); File.WriteAllBytes(path, resultBytes); var progress = ((float)index / files.Count); print(progress); yield return(null); } print("complete"); }
IEnumerator GenerateRoutine() { string[] files = Directory.GetFiles(loadDirectoryPath); files = files.Where(e => targetExtensions.Contains(Path.GetExtension(e))).ToArray(); for (var i = 0; i < files.Length; i++) { var bytes = File.ReadAllBytes(files[i]); baseTexture.LoadImage(bytes); baseTexture.Apply(); baseImageRenderer.material.mainTexture = baseTexture; var size = EMath.GetNormalizedExpandAspect(new Vector2(baseTexture.width, baseTexture.height)); baseImageRenderer.transform.localScale = new Vector3(size.x, size.y, 1f); clampCamera.Render(); yield return(null); //Aに画像をセット imageARenderer.material.mainTexture = clampedTexture; filterGroup.Filter(clampedTexture); yield return(null); var filteredTexture = filterGroup.GetTexture(); imageBRenderer.material.mainTexture = filteredTexture; resultCamera.Render(); yield return(null); TextureUtils.RenderTexture2Texture2D(resultRenderTexture, resultTexture); var resultBytes = resultTexture.EncodeToJPG(); var path = Path.Combine(saveDirectoryPath, (i + 1) + ".jpg"); File.WriteAllBytes(path, resultBytes); var progress = ((float)i / files.Length); EditorUtility.DisplayProgressBar("Processing", "processing...", progress); yield return(null); } EditorUtility.ClearProgressBar(); print("complete"); }