- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
!!!リソースとしてText(TextAsset)を取得
「[[リソースとしてObjectを取得|unity_script_get_resources_object]]」で、
「TextAsset」を取得することでテキストファイルを読み込むことができます。
Unityのプロジェクトで、
Assets
xxxx.unity
[Scripts]
[Resources] <== コレ
[text]
test.txt
hoehoe.txt
のように「Resource」フォルダを作成し、この中にテキストファイルを格納しておきます。
!!リソースの読み込み
TextAsset t = Resources.Load("text/test", typeof(TextAsset )) as TextAsset;
のようにするとテキストの読み込み。
TextAsset t = Resources.Load("text/hoehoe", typeof(TextAsset)) as TextAsset;
のようにするとテキストの読み込み。拡張子は指定しません。
string str = t.text;
に文字列が格納されています。なお、テキストは読み取り専用です。
----
{{lastmodified}}