• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Dec 11, 2014 at 06:14 AM by Prasanna for the following reason:

Found it own

avatar image
3
Question by Prasanna · Dec 03, 2014 at 07:46 AM · screenshotgallerycapturescreenshot

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Prasanna · Dec 08, 2014 at 09:24 AM 0
Share

Anyone there to solve this issues?

1 Reply

  • Sort: 
avatar image
4
Best Answer

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image raj231 · Jan 29, 2015 at 07:55 AM 0
Share

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;
                      }
                  }
avatar image Prasanna · Jan 29, 2015 at 08:02 AM 0
Share

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$$/"

avatar image rameshkumar Prasanna · May 02, 2016 at 11:12 AM 0
Share

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?

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to save a screenshot to the camera roll (picture gallery)? 3 Answers

Screenshot is not saving to Gallery and folder 2 Answers

Screenshot 0 Answers

use computer's desktop as a material 0 Answers

[WP8] Application.CaptureScreenshot() image not shown in gallery 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges