- Home /
Load image from document directory for iphone
Hi i am working on unity 3d app, i have an url of image and i successfully download image from that url and store into document directory path and path is: /var/mobile/Applications/4EA2C956-FCA1-4552-AEE5-611A55B26CF5/Documents/sample.jpg, now i getting stuck into how to retreive image and show on as a texture i did following code.
WWW imageToLoadPath = new WWW(/var/mobile/Applications/4EA2C956-FCA1-4552-AEE5-611A55B26CF5/Documents/sample.jpg) //rendering texture imageToLoadPath.LoadImageIntoTexture(mIconPlane.renderer.material.mainTexture as Texture2D);
I am getting confuse how to accomplish this task and also i want to do same videos like my path will be /var/mobile/Applications/4EA2C956-FCA1-4552-AEE5-611A55B26CF5/Documents/sampleVideo.mp4. This will be great for me. Thanks in advance.
Answer by Paulius-Liekis · Dec 04, 2012 at 12:44 PM
You need to add load of the file (this code has to be in coroutine):
WWW imageToLoadPath = new WWW(/var/mobile/Applications/4EA2C956-FCA1-4552-AEE5-611A55B26CF5/Documents/sample.jpg) //rendering texture
yield return imageToLoadPath; // <- the actual load of file
imageToLoadPath.LoadImageIntoTexture(mIconPlane.renderer.material.mainTexture as Texture2D);
BTW: why don't you load the image from the net using WWW class directly?
This is my requirement to load images all before app start and then load from disk.
Your answer
Follow this Question
Related Questions
Open iPhone Native Action sheet in Unity3d 1 Answer
Adding a Unity 3D view on top of UIKit again 0 Answers
Initiating a rich prefab runtime 0 Answers
Download then open image on IOS 0 Answers
Memory management theory question 1 Answer