- Home /
Unity can not access StreamingAssets on IOS
Now i'm working on a project which created by others. I need access image files stored in StreamingAssets folder. This is my C# code below:
IEnumerator Start () {
_image = gameObject.GetComponent <RawImage>();
string url = "file://" + System.IO.Path.Combine (Application.streamingAssetsPath, name);
WWW www = new WWW(url);
yield return www;
if (www.error == null)
{
_image.texture = www.texture;
}
else
{
Debug.Log ("[test] error : " + www.error);
}
}
I can totally make sure the file is right there. And it's working perfect when i run on Unity Editor. But it shows "Unsupported URL" after i build as ios and run at my ios device.
I am confused for this question for a long time. So I decide to do a test by creating a totally new project and add a new scene, a new script, a png image. It's working perfect when i run on iPhone after build it.
And now i do not know how to find the source of this question. Hope someone can help me. Thanks in advance.
Answer by UnityCoach · Feb 26, 2017 at 01:13 PM
I'm pretty sure you don't need the "file://" part. It's been a while since I used this. Check it out here.
I tried to remove it but it still not working. But it was worked after i create a new project and paste current code. So i guess maybe there are some problems exists in current project. Do you have any ideas of what may cause this happen?
Your answer
Follow this Question
Related Questions
WWW not working with https in iOS builds 1 Answer
IOS Streaming crash 0 Answers
iOS use WWW to access StreamingAssets get erro 1009 1 Answer
WWW in iOS does not set user agent header 1 Answer
Unity www class crashes on iOS 64 bit 2 Answers