Hey. I’m trying to make a game that works with tracked music and I’ve been loading them from an http or file:// to retrieve their bytes using www.bytes. I can’t seem to get “file://” to work on the iPhone, though, as the Resource folder doesn’t seem to be in the same spot in relation to Application.dataPath. Can anyone tell me where the contents of the resources folder are held on the iPhone? Also, is there any way I can get a byte array from an AudioClip after loading it using Resources.Load without making it a .bytes file instead?
There isn’t a Resources folder in a build, iPhone or otherwise. You can use System.File.IO and ReadAllBytes, but you’d have to store the files separately somewhere and not in Resources.
–Eric
Thanks for pointing that out. That will help. I’ll probably use the documents folder for most of this, but what about the streamedassets folder? It’s contents seem to show up under “/raw” in the build.
Ok. I’ve begun to use the Documents folder. In the editor, I’m looking in /Documents/. On iPhone, I’m looking in the app’s documents folder. I set up the app for file sharing and put the same files in there, and I’m printing out the contents of the folder to make sure they are there. It doesn’t seem to load on the iPhone, however. I’m using WWW, and www,bytes is showing a length of 0, so I guess it isn’t loading anything. Loading the same file from a url using http:// works just fine, but file:// seems to be giving me trouble on the iPhone. I’m checking for “file:///var/mobile/Applications/[appID]/Documents/DEADLOCK.XM” and DEADLOCK.XM does exist in the Documents folder. Any ideas?
I have an open bug with Unity about this. Loading audio files using WWW from the Documents directory or app bundle always fails.