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 /
avatar image
0
Question by siberman · Sep 25, 2012 at 07:48 AM · iosscreenshotexistsdocuments

iOS Find ScreenShot

Hello,

I know there are questions relating to this, but i am having problems that don't seem to be covered. Basically i'm using Application.CaptureScreenshot(), trying to yield until the file has been created, then apply this file to a texture. Works perfectly in editor, not on iOS though. I was having trouble with the yield, so i did a test with WaitForSeconds, and it just can't find the file. I've looked on the device though, and they are there, in the documents folder, as i'd expect from from what i've read about CaptureScreenshot.

I need to actually save the file as i want to post it to FB once i sort this out.

Any help would be GREATLY appreciated. Thanks.

 IEnumerator TakeScreenshotAndLoadItIntoTexture(string filename) {
         
         
         
         Application.CaptureScreenshot(filename);
         
         
         /*while(!File.Exists(filename)){
             debugString = "Saving";
             yield return null;    
         }
          */
         
         FileInfo info = new FileInfo(filename);
         
         while(info == null || info.Exists == false){
             debugString = "Saving";
             info = new FileInfo(filename);
             yield return null;
         }

            debugString = "Saved";
         WWW screenShot = new WWW("file://" + filename);
         
             yield return screenShot;
             print ("Loading");
             debugString = "Loading";
         
         print("Done " + Time.time);
         
         previewTexture = screenShot.texture;

}

btw, i call it with:

 StartCoroutine(TakeScreenshotAndLoadItIntoTexture(Application.persistentDataPath +"screenshot" + "_" + System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".png"));
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by udaanparvaz · Sep 25, 2012 at 01:55 PM

The Application.captureScreenshot("anyname.png"); save the png to documents folder itself, you don't need to give it a path. What you are doing here is saving a screenshot of name (Application.persistentDataPath +"screenshot" + "_" + System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".png") you should only pass the name...not the path to documents directory.

Please see into it.

Comment
Add comment · Show 2 · 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 siberman · Sep 25, 2012 at 11:41 PM 0
Share

Hey,

Thanks for the reply. Originally i was passing only the name as you suggested, i added the Application.persitentDataPath in a effort to eli$$anonymous$$ate any possible path issues. What i'm saying is the result is the same regardless. Neither of the while statements ter$$anonymous$$ate even though the file is created.

avatar image udaanparvaz · Sep 26, 2012 at 05:36 AM 0
Share

Have you tried passing the path manually ins$$anonymous$$d of giving the filename parameter to it?? Because I successfully tested this if(File.exists(Application.persistentDataPath+"/screenshot.png")) { //where my Application.captureScreenshot("/screenshot.png"); }

This method checked successfully the existence of my screenshot...This was tested on IOs just yesterday....I had to take the screenshot to gallery so i was checking the file existence before giving it to my native code....Please do keep in $$anonymous$$d that Unity takes some time to write the screenshot at the documents path...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Play audio from iOS documents folder with U3DXT 0 Answers

Does Application.CaptureScreenshot leak memory? (iOS) 0 Answers

Is it possible to trigger the iPad screenshot functionality from an application without button combination? 0 Answers

How do I include example resources in my iPad build? 1 Answer

Problem with saving screenshot 0 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