////////////////////////////////////////////
Unityで外部テキストファイルを読み書きしてみる。
////////////////////////////////////////////
------------ 1 -------------
新規でProjectを作る
ReadWriteSampleとした

練習は、PathTestObjという名前の
空オブジェクトを作り

PathTestScrという、C#Scriptファイルを作る


まずはPathを調べる。
------ PathTestScr.cs -------
using UnityEngine;
using System.Collections;
public class PathTestScr : MonoBehaviour
{
private string pathtxt = "";
// Use this for initialization
void Start() {
string txt = Application.dataPath;
string txt2 = Application.persistentDataPath;
pathtxt = "dataPath:" + txt + "\npersistentDataPath:" + txt2;
Debug.Log(pathtxt);
}
// Update is called once per frame
void Update() {
}
void OnGUI() {
GUI.TextArea(new Rect(5, 5, Screen.width, 50), pathtxt);
}
}
------ PathTestScr.cs -------
このScriptをPathTestObjに付けると
Consoleに、Pathが表示される
私の場合は
dataPath:D:/UnityData/ReadWriteSample/Assets
persistentDataPath:C:/Users/User/AppData/LocalLow/DefaultCompany/ReadWriteSample
プロジェクトは、D:/UnityData/ReadWriteSample/
にある。
- 関連記事
-
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 2017/02/19(日) 22:35:47|
- Unity
-
| トラックバック:0
-
| コメント:0