Most assets in Unity are combined into the project when it is built. However, it is sometimes useful to place files into the normal filesystem on the target machine to make them accessible via a pathname. An example of this is the deployment of a movie file on iOS devices; the original movie file must be available from a location in the filesystem to be played by the PlayMovie function.
To make files available on the filesystem, the files must be placed inside a folder called
StreamingAssets. These files will be skipped from being packaged into the resources and will be copies verbatim to a particular folder (
Application.streamingAssetsPath) on the target machine.
For reference, the location of this folder varies per platform:
On a desktop computer (Mac OS or Windows) the location of the files can be obtained with the following code:
path = Application.dataPath + "/StreamingAssets";
On iOS, you should use:
path = Application.dataPath + "/Raw";
On Android, you should use:
path = "jar:file://" + Application.dataPath + "!/assets/";
One thing to keep in mind for Android is that the files are stored inside the .jar file. To access the files from Streaming Assets, one must use Unity's
WWW class to retrieve the file.