Skip to content

Commit

Permalink
fixed screenshot save location for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
katboi01 committed Nov 16, 2024
1 parent b3dbd45 commit 38c7f9f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions Assets/Scripts/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ public static void TakeScreenshot()
height = height == -1 ? Screen.height : height;
var image = GrabFrame(camera, width, height, UmaViewerUI.Instance.SSTransparent.isOn);

string fileName = Application.dataPath + "/../Screenshots/" + string.Format("UmaViewer_{0}", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff"));
#if UNITY_ANDROID && !UNITY_EDITOR
string fileDirectory = Application.persistentDataPath + "/../Screenshots/";
#else
string fileDirectory = Application.dataPath + "/../Screenshots/";
#endif

string fileName = fileDirectory + string.Format("UmaViewer_{0}", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff"));
byte[] pngShot = ImageConversion.EncodeToPNG(image);
Directory.CreateDirectory(Application.dataPath + "/../Screenshots");
Directory.CreateDirectory(fileDirectory);
//fixes "/../" in path
var fullpath = Path.GetFullPath($"{fileName}.png");
File.WriteAllBytes(fullpath, pngShot);
Expand Down
10 changes: 8 additions & 2 deletions Assets/Scripts/uGIF/CaptureToGIFCustom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ public IEnumerator Encode (float fps, int quality)

IEnumerator WaitForBytes() {
while(bytes == null) yield return new WaitForEndOfFrame();
string fileName = Application.dataPath + "/../Screenshots/" + string.Format("UmaViewer_{0}", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff"));
Directory.CreateDirectory(Application.dataPath + "/../Screenshots");

#if UNITY_ANDROID && !UNITY_EDITOR
string fileDirectory = Application.persistentDataPath + "/../Screenshots/";
#else
string fileDirectory = Application.dataPath + "/../Screenshots/";
#endif
string fileName = fileDirectory + string.Format("UmaViewer_{0}", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff"));
Directory.CreateDirectory(fileDirectory);
//fixes "/../" in path
var fullpath = Path.GetFullPath($"{fileName}.gif");
File.WriteAllBytes(fullpath, bytes);
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 2.1.17
bundleVersion: 2.1.18
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 38c7f9f

Please sign in to comment.