Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Application.streamingAssetsPath

マニュアルに切り替える
public static string streamingAssetsPath;

説明

StreamingAssets フォルダーへのパスが含まれています(読み取り専用)

もし "StreamingAssets" フォルダーが Unity プロジェクトの Asset フォルダーにある場合、 それはプレイヤービルドにコピーされ Application.streamingAssetsPath によってパスを取得することができます。

いくつかのプラットフォームでは Web プラットフォーム上でファイルシステムにアクセスできなかったり、 Android では .apk ファイルの中に圧縮されていたりしてアクセスすることができないことに注意してください。 これらのプラットフォームでは、URL は WWW クラスを使用することによって返されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "MyFile"); public string result = ""; IEnumerator Example() { if (filePath.Contains("://")) { WWW www = new WWW(filePath); yield return www; result = www.text; } else result = System.IO.File.ReadAllText(filePath); } }