We have unity for iphone and android.
with unity iphone we are puting images into a folder called DATA and loading them at runtime.
It isnt working with our android build and we were wondering if there was a different directory to put our files in to reference them.
Hmmm… Sorry for being vague. The Data folder is something that xcode uses. We are putting jpgs in there and referencing them in. WE are new to building for android and my dev wants to open the apk file and put the jpgs in there so he can reference them like we can do with our ios unity build. Does that mkae sense?
Hey there,
My developer has spent over 7 full days trying every solution possible to load external JPGS on the android device.
None of the methods we have tried have worked. If anyone can think of a solution I will hire them to do this.
Thanks,
Chris
Ok. It seems that the problem is getting the jpg in the build. Our developer has tried many methods and still hasnt been able to do it. Does anyone have a suggestion for this?
use the Eclipse scheme linked to in an earlier post.
In all three cases the file will show up under /assets inside the .apk and can be loaded from “jar:file://” + Application.dataPath + “!/assets/<file_name>”.
So, I am having the same issue loading files from StreamingAssets. Unzipping the .apk shows that the files are definitely in the assets folder. When I go to load them using a StreamReader using the path below I get the exception below:
I’ll give it a shot but it sure does ruin the cross platform goodness that StreamingAssets provides. Is there really no way to get at the contents of the assets folder without resorting to a plugin?
Yes, that’s because you need to use WWW() to access the data. Remember that the files you are trying to access are sitting inside the .apk and are not accessible as plain files.
That only makes sense if the files are a) images, and b) accessed from Java code.
Prime31 is trying to load .json files, and those are not supported in res/drawable.
Copying your files to the StreamingAssets folder will have the exact same effect as putting the files under Assets/Plugins/Android/assets, except that files under StreamingAssets are never compressed (inside the .apk).
You can access these files through the WWW(“jar:file://…”) interface described earlier. Or through a plugin / Java code.
Yeah, I guess I was hoping Unity took care of creating an AssetManager and reading in the InputStream by way of magic. I’ve switched gears and stopped using StreamingAssets for cross platform stuff. As a feature request it would be nice if there was a way out of the box to read in a file from StreamingAssets to keep parity with the other platforms.
That’s exactly what I ended up doing. I just felt more comfortable with memory management being able to wrap a StreamReader in a using block and reading it line by line. The TextAsset path will work fine though.