• 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 t$$anonymous$$s, 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 t$$anonymous$$s 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 t$$anonymous$$s out.

Any help would be GREATLY appreciated. Thanks.

 IEnumerator TakeScreenshotAndLoadItIntoTexture(string filename) {
         
         
         
         Application.CaptureScreenshot(filename);
         
         
         /*w$$anonymous$$le(!File.Exists(filename)){
             debugString = "Saving";
             yield return null;    
         }
          */
         
         FileInfo info = new FileInfo(filename);
         
         w$$anonymous$$le(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 eliminate any possible path issues. What i'm saying is the result is the same regardless. Neither of the while statements terminate 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 instead 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 mind 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

How do i get screenshots for apple submission? 3 Answers

Running Camera roll from unity app 0 Answers

Share Screenshot Image to Facebook with Facebook SDK 0 Answers

Strange error uploading screenshots to iTunes Connect 0 Answers

How to wait till the screenshot is saved? 1 Answer


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