Fix frame capturing path

This commit is contained in:
nlitkowski 2021-12-19 23:34:46 +01:00
parent 4a6bdf0e96
commit 7cea4cd4e8

View File

@ -7,7 +7,7 @@ using UnityEngine;
public class Main : MonoBehaviour public class Main : MonoBehaviour
{ {
#region Constants #region Constants
readonly string capturedFramesPath = Path.Combine(Application.dataPath, "..", "..", "capturedframe"); string capturedFramesPath = Path.Combine(Application.dataPath, "..", "..", "Trees");
#endregion #endregion
#region Camera GUI fields #region Camera GUI fields
@ -141,6 +141,8 @@ public class Main : MonoBehaviour
} }
} }
capturedFramesPath = Path.Combine(capturedFramesPath, tree1.name);
bool exists = Directory.Exists(capturedFramesPath); bool exists = Directory.Exists(capturedFramesPath);
if (!exists) Directory.CreateDirectory(capturedFramesPath); if (!exists) Directory.CreateDirectory(capturedFramesPath);
@ -348,7 +350,7 @@ public class Main : MonoBehaviour
RenderTexture.active = currentRT; RenderTexture.active = currentRT;
++FrameCounter; ++FrameCounter;
string path = Path.Combine(capturedFramesPath, tree1.name + "-" + FrameCounter.ToString() + ".png"); string path = Path.Combine(capturedFramesPath, FrameCounter.ToString() + ".png");
byte[] bytes = offscreenTexture.EncodeToPNG(); byte[] bytes = offscreenTexture.EncodeToPNG();
File.WriteAllBytes(path, bytes); File.WriteAllBytes(path, bytes);
Debug.Log(path); Debug.Log(path);