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 oliver-jones · Jun 12, 2015 at 06:06 PM · ioswwwloadnet

iOS - WWW Doesn't work on Local Load

Hello,

I'm building a local save/load system for textures for iOS, and I'm working with both .NET and WWW systems. My WWW system doesn't seem to work for loading on iOS. Both work fine in the Editor.

.NET (Works):

 var pathtype = GetDataPath();
 var path = pathtype + "/" + dir;
 var filepath = path + "/" + filename;
 
 var imgRaw = File.ReadAllBytes(filepath);
 var img = new Texture2D(size.x, size.y);
 img.LoadImage(imgRaw);

WWW (Doesn't Work):

 var pathtype = GetDataPath();
 var path = pathtype + "/" + dir;
 var filepath = "file://" + path + "/" + filename;
 
 var www = new WWW(filepath);
 var img = www.texture;

GetDataPath() basically just passes in the persistentDataPath or just a normal dataPath depending if I'm running it on iOS or in the Editor.

My debugger says it has been loaded, and the directory looks okay to me:

.NET (Works):

/var/mobile/Containers/Data/Application/***/Documents/my_dir/profile.png

WWW (Doesn't Work):

file:///var/mobile/Containers/Data/Application/***/Documents/my_dir/profile.png

Comment
Add comment · Show 8
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 zach-r-d · Jun 13, 2015 at 10:44 AM 0
Share

Out of curiosity, if the .NET version works, why do you want to use WWW?

avatar image oliver-jones · Jun 13, 2015 at 12:58 PM 0
Share

Because I'm also using this system to load AudioClips to, and I can't figure out how to do that via .NET, whereas WWW has classes to do it. But I can't get it to work on iOS

avatar image zach-r-d · Jun 13, 2015 at 01:33 PM 0
Share

To do it without WWW you'd need to find a library to decode the file into a format that AudioClip.SetData can accept (unless there's some .NET/$$anonymous$$ono class that can do it). It's doable but seems like it could be a mess, so WWW is indeed preferable.

What's the output when you do Debug.Log(www.error)?

avatar image oliver-jones · Jun 13, 2015 at 06:47 PM 0
Share

Yeah I thought that would be the case. Ideally, I'm trying to move from .NET, to WWW. When I run the program in Editor, no errors and the textures load fine.

But on iOS, the textures load as a question mark (Doc states: If the data is not a valid image, the generated texture will be a small image of a question mark). And Debug.Log isn't saying anything. So theres not error in terms of finding the image - so the directory must be okay.

Could it be that because I'm saving the image initially via .NET, which may cause a corruption? Yet, it works fine on the editor.

 var bytes = img.EncodeToPNG();
 File.WriteAllBytes( path, bytes );
avatar image zach-r-d · Jun 13, 2015 at 08:05 PM 0
Share

Try putting the loading in a coroutine and doing yield www; between creating the www and accessing .texture

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sasantv · Jul 20, 2016 at 02:25 PM

You don't need file:/// in WWW load for iOS

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

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

24 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

Related Questions

Dinamic name for data save 0 Answers

Webplayer crash on LoadImageIntoTexture call 1 Answer

Is it possible to load a script from a url? 1 Answer

the texture appear rubbish 1 Answer

Load audioclip from folder on computer into game, in runtime 3 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