- Home /
Found it own
Saving Path for Screenshot
Hi, i have a script for taking screen and save into default location. But i want to make that location manually, where can i add that in this script and now i can't see those screenshots in gallery. I want to see that screenshot into my gallery too. Thanks in advance, here is the script.
using UnityEngine;
using System.Collections;
public class Capture : MonoBehaviour
{
private int Screen_Shot_Count = 0;
public GUITexture Capture_Model;
void Update()
{
if (Input.touches.Length > 0)
if(Capture_Model.HitTest (Input.GetTouch(0).position))
{
string Screen_Shot_File_Name;
do
{
Screen_Shot_Count++;
Screen_Shot_File_Name = "Screenshot_" + Screen_Shot_Count + ".png";
}
while (System.IO.File.Exists(Screen_Shot_File_Name));
Application.CaptureScreenshot(Screen_Shot_File_Name);
}
}
}
Does anyone know how to do this?
Answer by Prasanna · Dec 11, 2014 at 06:13 AM
Finally found a solution.
using UnityEngine;
using System.Collections;
public class Capture : MonoBehaviour
{
// Store more screenshots...
private int Screen_Shot_Count = 0;
// Screenshot taking by touch the button.
public GUITexture Capture_Model;
// Check the Shot Taken/Not.
private bool Shot_Taken = false;
// Name of the File.
private string Screen_Shot_File_Name;
void Update()
{
if (Input.touches.Length > 0)
// Finger hit the button position.
if(Capture_Model.HitTest (Input.GetTouch(0).position))
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
// Increament the screenshot count.
Screen_Shot_Count++;
// Save the screenshot name as Screenshot_1.png, Screenshot_2.png, with date format...
Screen_Shot_File_Name = "Screenshot__" + Screen_Shot_Count + System.DateTime.Now.ToString("__yyyy-MM-dd") + ".png";
Application.CaptureScreenshot(Screen_Shot_File_Name);
Shot_Taken = true;
}
}
if(Shot_Taken == true)
{
string Origin_Path = System.IO.Path.Combine(Application.persistentDataPath, Screen_Shot_File_Name);
// This is the path of my folder.
string Path = "/mnt/sdcard/DCIM/Inde/" + Screen_Shot_File_Name;
if(System.IO.File.Exists(Origin_Path))
{
System.IO.File.Move(Origin_Path, Path);
Shot_Taken = false;
}
}
}
}
This will help someone.
Hi Prasanna, Does it works on android? I've tried your code but it's notworking.
if (GUI.Button(new Rect(Screen.width-85,Screen.height-(Screen.height-80),80,80), Zoom_Tex,camera_icon_style)) {
Screen_Shot_File_Name = model.name + System.DateTime.Now.ToString("__yyyy-$$anonymous$$$$anonymous$$-dd") + ".png";
Application.CaptureScreenshot(Screen_Shot_File_Name);
Shot_Taken = true;
//Debug.Log("path save is "+Screen_Shot_File_Name);
}
if(Shot_Taken == true)
{
string Origin_Path = System.IO.Path.Combine(Application.persistentDataPath, Screen_Shot_File_Name);
Debug.Log("Origin_Path save is "+Origin_Path);
// This is the path of my folder.
string Path = "/mnt/sdcard/DCI$$anonymous$$/Inde/" + Screen_Shot_File_Name;
Debug.Log("Path save is "+Path);
if(System.IO.File.Exists(Origin_Path))
{
System.IO.File.$$anonymous$$ove(Origin_Path, Path);
Debug.Log("Path_move save is "+Path);
Shot_Taken = false;
}
}
Tell me exactly, which is not working?, Is that having problem with taking screenshot? or store the folder?. You have to remove the Inde from your path or you have to create a folder name called Inde in the path "/mnt/sdcard/DCI$$anonymous$$/"
is it working fine or what ? actually i have the source code like
public void SaveScreenShot() { // Increament the screenshot count. Screen_Shot_Count++; // Save the screenshot name as Screenshot_1.png, Screenshot_2.png, with date format... Screen_Shot_File_Name = "Screenshot_" + Screen_Shot_Count + System.DateTime.Now.ToString("_yyyy-$$anonymous$$$$anonymous$$-dd") + ".png"; Application.CaptureScreenshot(Screen_Shot_File_Name); Shot_Taken = true;
if (Shot_Taken == true)
{
string Origin_Path = System.IO.Path.Combine(Application.persistentDataPath, Screen_Shot_File_Name);
// This is the path of my folder.
string Path = "/mnt/sdcard/DCI$$anonymous$$/Camera/" + Screen_Shot_File_Name;
if (System.IO.File.Exists(Origin_Path))
{
System.IO.File.$$anonymous$$ove(Origin_Path, Path);
Shot_Taken = false;
}
}
}
i am not getting any pics do i need to change anything in this source or what let me know?
Follow this Question
Related Questions
Screenshot is not saving to Gallery and folder 2 Answers
How to save a screenshot to the camera roll (picture gallery)? 3 Answers
Upload image to server and display it for others? 0 Answers
Capturing 360 Image causes to darken the image and show ghosting and artifacts 0 Answers
Share Button 3 Answers