Unity は、プロジェクトのビルド時に、シーンとアセットを組み合わせて、生成されたプレイヤー内のバイナリファイルにします。ただし、ファイルをターゲットマシン上の通常のファイルシステムに配置して、パス名を使って利用できるようにすることができます。例えば、iOS デバイスにムービーファイルをデプロイする場合、元のムービーファイルはファイルシステム内の場所から PlayMovie 関数を使用して再生できるようにする必要があります。このフォルダには、オンデマンドのダウンロードではなくプレイヤーのインストール時に直接配布する アセットバンドル を含めることも可能です。
Unity は、Unity プロジェクト内の StreamingAssets (大文字小文字を区別します) というフォルダーに配置された全てのファイルを、ターゲットマシンの特定のフォルダーにそのままコピーします。このフォルダーを取得するには、Application.streamingAssetsPath プロパティを使用します。StreamingAssets の場所の取得は、必ず Application.streamingAssetsPath を使用して行うことをお勧めします。これは必ずプラットフォーム上でアプリケーションが実行されている正確な場所を示すからです。
Application.streamingAssetsPath によって返される場所はプラットフォームごとに異なります。
Application.dataPath + "/StreamingAssets" を使用します。Application.dataPath + "/Resources/Data/StreamingAssets" を使用します。Application.dataPath + "/Raw" を使用します。"jar:file://" + Application.dataPath + "!/assets" を使用します。Application.streamingAssetsPath returns a HTTP URL that points to the StreamingAssets/ path on the web server. For example, http://localhost:8000/unity_webgl_build/StreamingAssets/ is returned when your application is running against a local development server.On Android and the Web platform, it’s not possible to access the streaming asset files directly via file system APIs and streamingAssets path because these platforms return a URL. Use the UnityWebRequest class to access the content instead.
ノート:
streamingAssets パスは読み取り専用です。ランタイムに streamingAssets ディレクトリに変更を加えたり新しいファイルを書き込んだりしないでください。