When the project I am working in is on the C drive, this works perfectly well. When the project I working in is not on the C drive (the D drive, for instance), this fails with the following error:
You are trying to load data from a www stream which had the following error when downloading.
Couldn’t open file /Users//AppData/LocalLow//\debug.assetbundle
This error would seem to indicate that the drive name was lost somewhere. Combined with the symptoms of the error I’ve been encountering, it also seems that the drive is being defaulted to whatever drive the current project is on. Does anyone know how to correctly specify a specific drive name for use with class WWW when running in the Windows Editor?
OMG! I just got the same problem. Like you say, I strongly suspect if there’s some problem with differen drive symbol. My project is in D drive, and obviously the presistant data path is in C drive. I used File.Exist and FileStream the get the assetbunle. And it works just fine indicating there is no problem in url. Also if I store the assetbundle in other place from C drive, it works fine too.
Now that u got this problem too, I’m thinking this may be kind of Editor bugs? I gona try it on mobile device, hopes that will work fine.
Just Got the problem resolved! amazing, LOL.
this’s my old url:
string url = “file://” + Application.persistentDataPath + “/Streamed-streamScene1.unity”;
I just add another slash after ‘file’ and it works…
string url = “file:///” + Application.persistentDataPath + “/Streamed-streamScene1.unity”;
Ironically, I thought something like that might be the problem… so I decided specifically to use the URI builder to try and resolve formatting issues on the path. The URI builder gave me file:///, but Unity’s file I/O failed to interpret the rest of the URLEncoded string. Manually specifying file:/// instead of using any kind of standardized URI formatting resolved my problem as well.
Had a similar problem with my game trying to load across drives. Application.persistentDataPath was located on the C drive, every user who reported load failures was running from a non-C drive.
Sparrow’s solution worked for me. Just needed to change “file://” to “file:///” (with three slashes) on all new WWW() calls.
Hi! sorry to post in a solved post, but I have been searching for this for a while. I am trying to stream some WAV files from my Application.persistentdataPath. It works perfectly fine in the emulator, but it does not when built for Android. I have already tried every solution proposed in this post, and no results. Any hint?? Thanks a lot beforehand!! The code:
void Start()
{
audio = GetComponent<AudioSource>();
findFiles(); //Call it more times to update array. If updated, put old files at the end
local_gui = GameObject.Find("myGUI").GetComponentInChildren<myGUIScript>();
}
public void findFiles()
{
files = Directory.GetFileSystemEntries(Application.persistentDataPath + Path.DirectorySeparatorChar + "downloadedSounds" + Path.DirectorySeparatorChar, "*.wav"); // get path from download client
if (files.Length > 0)
{
StartCoroutine(StartAudio());
}
}
public IEnumerator StartAudio()
{
float doubleToFloat = (float)DataProcessing.GetNearSoundFiles(files[0]);
if (doubleToFloat < playbackThreshold)
{
Debug.Log("Loading files for playback...");
//Loop over those getting filePath.
//Uri uri = new Uri(Path.Combine(Environment.CurrentDirectory, files[0]));
//Uri uri = new Uri(WWW.EscapeURL(files[0]));
// Uri uri = new Uri(files[0]);
string newPath = "file:///" + files[0];
//Then later get the absolute path from the Uri
//filename = new WWW("file:///" + uri.AbsolutePath);
filename = new WWW(newPath);
loadingStuff = true;
yield return filename;
myAudioClip = filename.GetAudioClip(false);
audio.clip = myAudioClip;
audio.PlayOneShot(myAudioClip, mappedVolume);
Debug.Log("playing: " + files[0]);
loadingStuff = false;
}
}
}