My actual code:
function Update() {
if(Input.GetMouseButtonDown(0)) {
Debug.Log("foto");
Application.CaptureScreenshot(Application.dataPath + "Screenshot.png");
}
}
I need the path for the output of every photo for this function.
Thanks!
Application.persistentDataPath
of unity always points towards documents folder inIOS
and to/mnt/android/data/application-bundle-identifier/
forandroid
.And if you don't give the path for
Application.CaptureScreenshot
put instead give only the name for the screenshot it'll automatically get saved in the Documents folder ofIOS
haven't tested forandroid
.Hope this helps.
You can save files to Application.persistentDataPath. Unity apps do not have write permissions to
Application.dataPath
on Android or iOS devices.Also, don't forget to join the path and the folder name with a forward slash:
There are at least 3 ways for saving some kind of screenshot with Unity3D:
Application.CaptureScreenshot
,Texture2D.ReadPixels
andRenderTexture
.I only know about the first one:
Application.CaptureScreenshot
. It is for sure the simplest one. It doesn't take paths and it will save toApplication.persistentDataPath
orApplication.dataPath + "/../"
, depending on your platform. Unfortunately there's currently no way of knowing for sure or through code only - it's just broken in that way. Also, it is slow and it may take some seconds to process. It runs as a separate process so you should have an Update or a Coroutine waiting for the file to be created before using it for anything.If you want to choose where the file will be saved with it, you need to do something like this: