- Home /
iOS won't load streaming asset
Hello, I'm having a bit of trouble loading a file from the StreamingAssets folder on iOS. I have an asset named 'level2a' located in Assets/StreamingAssets. All I am doing is:
var path = new GoSpline( "level2a" );
I get a runtime error on the iOS device telling me that the file could not be found at "xxx/xxx/xxx/Data/Raw/level2a". This works perfectly fine in the editor. I have also tried:
var path = new GoSpline( Path.Combine(Application.streamingAssetsPath, "level2a"));
and I get the same error. Anyone have any idea what's going on here and how to get this to work? Thanks!
It sounds silly but did you check if level2 is currently in the Data/Raw/ folder ?
In the Unity project? The file is in Assets/Strea$$anonymous$$gAssets. Where else would I need to physically place it? I thought unity automatically bundles it in the correct path.
Unity copy all your Strea$$anonymous$$gAssets in your Xcode Project in the Data/Raw folder beside your Unity.xcodeproj.
But according to the documentation ( http://docs.unity3d.com/Documentation/$$anonymous$$anual/Strea$$anonymous$$gAssets.html ) Your path should be Application.dataPath + "/Raw/level2a"
Yes, Unity properly copied the file there (I see it in the Data/Raw folder) and even when I try Application.dataPath + "/Raw/level2a" it still gives me the file not found error. Ugh.
Can you try this one : path = Path.Combine(Path.Combine(Application.dataPath, "Raw"), pathAssetName);
I don't have Go$$anonymous$$it so i can't test but it seems to work for others users.
Answer by helios · Jul 11, 2013 at 03:24 AM
Ok, THAT was really frustrating. It was a freaking typo the whole time. I was referencing "Level2a" instead of "level2a". Apparently it is case sensitive on iOS, but not in the editor which is why it was working in there. Doh.. Thanks for all the help though, guys.
This saved me so much hunting, my issue boiled down to this and I was going nuts. When I came across this post I figured it had nothing to do with my issue, but I decided to check the case of my path anyways, sure enough, that was it! How aggrivating!
Answer by Graham-Dunnett · Jul 10, 2013 at 10:50 AM
Try this:
using UnityEngine;
using System;
using System.IO;
public class filebrowser : MonoBehaviour {
void ProcessFolder(string f) {
Debug.Log("Folder: " + f);
var txtFiles = Directory.GetFiles(f);
foreach (string currentFile in txtFiles) {
Debug.Log("File: " + currentFile);
}
string[] subs = Directory.GetDirectories(f);
foreach(string sub in subs)
ProcessFolder(sub);
}
// Use this for initialization
void Start () {
ProcessFolder(Application.dataPath);
}
// Update is called once per frame
void Update () {
}
}
Drop that onto your camera, then when the game starts up it'll iterate over the folder and subfolders from the Application data folder, and show you what is actually on the device. You can then use this to determine whether your asset is actually getting copied onto the phone or not. If it is there, then it would be odd to get a error when you try to access the file.
My results look like:
Folder: /var/mobile/Applications/{GUID}/test.app/Data
File: /var/mobile/Applications/{GUID}/test.app/Data/PlayerConnectionConfigFile
File: /var/mobile/Applications/{GUID}/test.app/Data/mainData
File: /var/mobile/Applications/{GUID}/test.app/Data/sharedassets0.assets
File: /var/mobile/Applications/{GUID}/test.app/Data/unity default resources
Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-CSharp.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-UnityScript.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-UnityScript.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Boo.Lang.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Mono.Security.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Mono.Security.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.Core.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.Core.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/UnityEngine.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mscorlib.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mscorlib.dll.mdb
Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono
Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono/2.0
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono/2.0/machine.config
Folder: /var/mobile/Applications/{GUID}/test.app/Data/Raw
File: /var/mobile/Applications/{GUID}/test.app/Data/Raw/test.txt
Note at the bottom of that list, you can see that there is a file called test.txt
in the Raw
folder. That test.txt
is there because it exists in the StreamingAssets
folder in my Unity project.
Hi, I was having the same problem so I went ahead and tried this. It's showing all the files are definitely on the device and in the correct location. However I still get file not found at that url. I'm using the application to construct the path. The only part I add myself is "file:/" at the beginning so that I avoid the "unsupported URL" error because I'm using WWW.
$$anonymous$$y url looks something like this:
file://var/mobile/Applications/{GUID}/my.app/Data/Raw/bundle.unity3d
Your answer

Follow this Question
Related Questions
iOS use WWW to access StreamingAssets get erro 1009 1 Answer
Store downloaded images to streemingassets folder Android/Ios 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
HandHeld video compression setting doesn't work in editor? 1 Answer
Application.dataPath + "/Raw" not loading texture on iOS? 0 Answers