fixed screenshot save location for Android
This commit is contained in:
@@ -26,9 +26,15 @@ public class Screenshot : MonoBehaviour
|
||||
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);
|
||||
|
||||
@@ -37,8 +37,14 @@ namespace uGIF
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user