• 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 sona.viswam · Jul 23, 2013 at 09:02 AM · texture

Not getting image from Persistant path in Android

I have a script to take screenshot and save that image and to show that image in a plane.

But not getting that texture.

 private string path;

 void Start () {
        path = Application.persistentDataPath;
     }

 void captureScreeshot(){ 
     Application.CaptureScreenshot(path + "/Screenshot.png");
     alert.text = "saved";
     StartCoroutine(saveScreenshot()); 
     onetimeBool = false;
 }
 IEnumerator saveScreenshot(){
     WWW imgfile = new WWW("file://" + path+ "/Screenshot.png");
     yield return imgfile;
     if(imgfile.error==null){
         img = new Texture2D(200, 200, TextureFormat.RGB24, false); 
         imgfile.LoadImageIntoTexture(img);
         alert.text = "got image";
         GameObject.Find("plane").renderer.material.mainTexture = img;
         
     }else{
         print(imgfile.error);
     }
 }

Images gets saved.

But I cannot open (load) image in windows system and android.

Getting error in system :

Couldn't open file /Users/ether/AppData/LocalLow/Company/Project/Screenshot.png

How to get it ???

Comment
Add comment · Show 6
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 PAEvenson · Jul 23, 2013 at 11:55 AM 0
Share

i think android needs to use jar preceding the file://

  WWW imgfile = new WWW("jar:file://" + path+ "/Screenshot.png");
avatar image sona.viswam · Jul 23, 2013 at 12:12 PM 0
Share

getting error: java.net.$$anonymous$$alformedURLException:java.lang. NullPointerException: Cannnot find "!/"

avatar image PAEvenson · Jul 23, 2013 at 12:37 PM 0
Share

hmm reading the unity script reference: http://docs.unity3d.com/Documentation/ScriptReference/Application.CaptureScreenshot.html

It says "On mobile platforms the filename is appended to the persistent data path."

try:

 Application.CaptureScreenshot("Screenshot.png");


avatar image sona.viswam · Jul 23, 2013 at 12:49 PM 0
Share

still not getting. i saved as your code. all other codes i kept as same

avatar image PAEvenson · Jul 23, 2013 at 12:54 PM 0
Share

hmm...Only other thing I can think of is that the file hasn't been saved before you try accessing it. Try adding:

 yield return new WaitForSeconds(2.0f);
 
 WWW imgfile = new WWW("file://" + path+ "/Screenshot.png");
     yield return imgfile;
     if(imgfile.error==null){
        img = new Texture2D(200, 200, TextureFormat.RGB24, false); 
        imgfile.LoadImageIntoTexture(img);
        alert.text = "got image";
         GameObject.Find("plane").renderer.material.mainTexture = img;
  
     }else{
        print(imgfile.error);
     }
Show more comments

0 Replies

· Add your reply
  • Sort: 

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

16 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

Related Questions

A node in a childnode? 1 Answer

How to Make a Character Flicker? 1 Answer

need help in texturing a city.. 2 Answers

Texture in Unity looks ugly but in Blender it's look Good 1 Answer

Importing blender model - no texture details 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