private IEnumerator TakePhoto(RenderTexture renderTexture) { yield return(Observable.TimerFrame(2).ToYieldInstruction()); // Take photo and set can save rt false SaveRenderTextureToFile(CurrentMmdObject.FilePath + ".png", renderTexture); Destroy(_fbxGameObject); MmdObjects.Remove(CurrentMmdObject); if (MmdObjects.Count == 0) { OnRenderComplete(); } Resources.UnloadUnusedAssets(); GC.Collect(); }
private void FixedUpdate() { // Save rt ass♂ we can if (!IsRendering.Value || IsSaving.Value) { return; } if (MmdObjects.Count != 0) { //OnRenderStart(); // Notify that start render System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { CurrentMmdObject = MmdObjects.First(); var rt = new RenderTexture(renderWidth, renderHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB) { name = $"{CurrentMmdObject.FileName}", depth = 0, anisoLevel = 0, dimension = TextureDimension.Tex2D, antiAliasing = 8 }; rtCamera.targetTexture = rt; IsSaving.Value = true; CreatePmx(); StartCoroutine(TakePhoto(rt)); } catch (Exception e) { Debug.LogError(e.Message); rtCamera.targetTexture = null; } } else { IsRendering.Value = false; rtCamera.targetTexture = null; } }
public void StartRender(MMDObject mmdObject) { MmdObjects.Add(mmdObject); IsRendering.Value = true; }