I have an AssetBundle caching system working great, saving it’s files in the application’s data directory and loading them through the WWW class.
I would rather have the cache saved in a non volatile directory to persist through game updates, so I changed the code to use (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor ? System.Environment.GetFolderPath (System.Environment.SpecialFolder.LocalApplicationData) + “/WhirldCache/” : System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + “/Library/Application Support/WhirldCache/”) instead. BTW: If anyone has a more elegant crossplatform way to access a data directory, that would be awesome!
For some reason, the WWW class has a fit if I point it to any files outside of the app’s data directory (even though my app has full permission to access the files), and Windows explorer can access them just fine at the path I am feeding the WWW class. Does anyone know why this is?
Good point! The file:// protocol prefix is added at another point in my code, I just neglected to mention it above.
To illustrate the issue, here’s a full path to a cached file on my machine: file://\C:\users\Aubrey\AppData\Local\WhirldCache\map.syn3h.com\UnityIsland\Whirld.utw
(Edit: the space in my url is created by the forum software…)
I paste this path in my webbrowser, and I am looking at the contents of the file.
I pass this path to the WWW api, and I get a “can’t open file error”.
(I tried it with /s too, but that didn’t help)
use .Replace(“\”,“/”) on the path you get from the system. the browser can do this for you, but unity won’t magically fix such things. Also the user is the one you run the application on, correct?
Sorry for my delayed response. For anyone else that runs into this issue (I already saw one on Unity Answers), I was generating paths that were devoid of the third slash before the drive letter designator.
Like you were saying Dreamora, the browser fixed this automatically - and Unity’s www class worked fine as soon as I did it manually.