Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 12:19 PM by Prasanna for the following reason:

Solved by own

avatar image
0
Question by Prasanna · Dec 11, 2014 at 06:55 AM · pathscreenshotuploadloadimageintotexture

Show Screenshot in display.

Hi world, am currently working an augmented reality project which have to take a screenshot and upload facility. I have done a screenshot script and save into custom path that's all working perfectly(but can't see into gallery another issue). Now when i took a screenshot its saved but i want to display suddenly onto my screen. This is my code for taking screenshot and save into the folder.

 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;
             }
         }
     }
 }

Now i want to solve this two problems.

  1. Display the screenshot once it taken.

  2. I can view the screenshot from gallery folder.

Comment
Add comment
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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Prasanna · Dec 11, 2014 at 12:15 PM

Finally found another way.

 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;
     public GUITexture Show_Screen;
     public GUITexture Close_Screen;
     // Check the Shot Taken/Not.
     private bool Shot_Taken = false;
     // Name of the File.
     private string Screen_Shot_File_Name, Path_Name;
     private string File_Path, Origin_Path;
     private byte[] Bytes_File;
     private Texture2D Screenshot;
 
     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);
             }
         }
 
         if(Close_Screen.HitTest (Input.GetTouch(0).position))
         {
             if (Input.GetTouch(0).phase == TouchPhase.Began)
             {
                 Screenshot = null;
                 Shot_Taken = true;
             }
         }
 
         if(Shot_Taken == true)
         {
             Origin_Path = System.IO.Path.Combine(Application.persistentDataPath, Screen_Shot_File_Name);
             // This is the path of my folder.
             File_Path = "/mnt/sdcard/DCIM/Inde/" + Screen_Shot_File_Name;
             if(System.IO.File.Exists(Origin_Path))
             {
                 System.IO.File.Move(Origin_Path, File_Path);
                 Shot_Taken = false;
             }
         }
     }
     void OnGUI()
     {
         if (Input.touches.Length > 0)       
         // Finger hit the button position.
         if(Show_Screen.HitTest (Input.GetTouch(0).position))
         {
             if (Input.GetTouch(0).phase == TouchPhase.Began)
             {
                 Path_Name = System.IO.Path.Combine(Application.persistentDataPath, Screen_Shot_File_Name);
                 Bytes_File = System.IO.File.ReadAllBytes(Path_Name);
                 Screenshot = new Texture2D(0, 0, TextureFormat.ATF_RGB_DXT1, false);
                 Screenshot.LoadImage(Bytes_File);
             }
         }
         
         if(Screenshot != null)
         {
             GUI.DrawTexture(new Rect(Screen.width/2 - 200, Screen.height/2 - 150, 400, 300), Screenshot);
         }
     }
 }
Comment
Add comment · Show 5 · 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 Prasanna · Dec 11, 2014 at 12:18 PM 1
Share

@taxvi, thanks for your help mate. that's really appreciated. Here i have only one doubt, my screenshots are working nicely and paths are perfect. But i can't see my images in the gallery, any idea for that. @taxvi, +1 for your answer. But this one is solved my problem.

avatar image taxvi · Dec 11, 2014 at 12:35 PM 0
Share

that I think is android specific question already. do you see the folder 'Inde' in your file browser?

avatar image Prasanna · Dec 11, 2014 at 12:42 PM 0
Share

Yes, i saw the folder. Because i created the folder not through scripts once i create a folder through script, my save path is not working.

avatar image taxvi · Dec 11, 2014 at 12:58 PM 0
Share

mm... I don't know, THIS post says unity does not have permission for writing outside its data folders :/ it's weird you actually can view your screenshot.

avatar image Prasanna · Dec 11, 2014 at 01:03 PM 0
Share

That's condition only for application.datapath not in application.persistantdatapath. We can create a path using application.persistantdatapath, now am trying to finding the way to create a runtime folder and make that as a path.

avatar image
1

Answer by taxvi · Dec 11, 2014 at 07:54 AM

have a look at WWW.LoadImageIntoTexture docs

Comment
Add comment · Show 9 · 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 Prasanna · Dec 11, 2014 at 07:56 AM 0
Share

Is this work with android? because currently am working android device.

avatar image taxvi · Dec 11, 2014 at 08:00 AM 0
Share

should work, it's working on iOS. I'm storing a my files in my app's temp folder and have no problems.

avatar image Prasanna · Dec 11, 2014 at 08:03 AM 0
Share

Thanks for your help, if i have any doubt let me ask you.

avatar image Prasanna · Dec 11, 2014 at 09:55 AM 0
Share

@taxvi, how can i add my mobile path url to this form.

avatar image taxvi · Dec 11, 2014 at 10:17 AM 0
Share

if the path is the local disk of the device it should be of a format "file:///homedir/someOtherDir/.../appDir/yourDir" make sure you have the "file:///" in the beginning of the url

Show more comments

Follow this Question

Answers Answers and Comments

26 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 avatar image

Related Questions

Load the sprite property of a png file from Application.persistentDataPath 2 Answers

capture the screenshot to iPhone photo gallery 2 Answers

I need to take a screenshot from a FLASH BUILD 1 Answer

I need to set the path for saving the pictures with an application for Android and IOS 2 Answers

File.Delete problems with Application.CaptureScreenshot 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges