- Home /
Screenshot multiple
Does anyone know how I can screenshot different scenes in the mobile phone.? I got this script but it only allow MAXIMUM OF ONE SCREENSHOT only, so everytime I tried to perform the screenshot it doesn't save anymore :(
void OnGUI() {
if (GUI.Button (new Rect(50,50,150,30), "Capture")) {
string filename = "shot.png";
Application.CaptureScreenshot(filename);
if (QCARRuntimeUtilities.IsPlayMode()) {
// if in PlayMode, the screenshot will be saved
// to the project directory
Debug.Log ("Saved screenshot to " + filename);
}
else {
// if running on Device, the screenshot will be saved
// to the Application.persistentDataPath directory
Debug.Log ("Saved screenshot to " + Application.persistentDataPath + "/" + filename);
}
}
}
Answer by robertbu · Mar 04, 2014 at 05:53 PM
Actually it allows multiple screen shots, but since you are always using the same file name, the last one taken is the only one you see. Try creating a unique file name each time it is called:
string filename = "shot"+Time.frameCount+"png";
Note is a solution for a single session. You'll have to come up with something else if this is for an end user or if you want to have it for multiple sessions. You could keep a shot count using PlayerPrefs and use that for example.
what would be the codes fort the multiple session ? :/
You could do something like this (untested):
int shotsTaken = PlayerPrefs.GetInt("ShotsTaken", 0);
shotsTaken++;
PlayerPrefs.SetInt("ShotsTaken", shotsTaken);
string filename = "Shot_"+shotsTaken+".png";
if I want to save the screenshot made in specific folder of the phone how will I do it?thank you Sir.
Please be careful to post comments on this answer as comments to this answer and not as a new answer.
If I want to save the screenshot made in specific folder of the phone how will I do it?thank you Sir.
I don't know for sure and Android and iOS may be different. There are sandboxing issue, so you cannot put them just anywhere. I suspect that your screen shots are stored in Application.persistentDataPath. You should be able to store them in a subfolder by specifying a path in the file name:
string filename = "ScreenShots/Shot_"+shotsTaken+".png";
Edit: I'm not at a place I can test out how things work at the moment. Application.CaptureScreenshot says nothing about default path, so you may have to supply the full path for use on the phone:
string filename = Application.persistentDataPath+"/ScreenShots/Shot_"+shotsTaken+".png";
Your answer
Follow this Question
Related Questions
Screenshot and save 0 Answers
Distribute terrain in zones 3 Answers
screenshot 0 Answers
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer