Application.dataPath
建議視窗開發中用的路徑:
windows: /Assets
IPone: Application/???/Name.app/Data
Android: /data/app/Name.apk
Application.persistentDataPath
Contains the path to a persistent data directory (Read Only).
平台中的公開目錄,文件持久性的保存不會因為應用程式更新或升級而刪除
windows: C:/Users/xxxx/AppData/LocalLow/CompanyName/ProductName
IPone: Application/???/Documents
Android: /data/data/Name/files
Application.streamingAssetsPath
專案目錄下面的 Assets/StreamingAssets
windows: /Assets/StreamingAssets
IPone: Application/???/Name.app/Data/Raw
Android: jar:file:///data/app/Name.apk/!/assets
Application.temporaryCachePath
Contains the path to a temporary data / cache directory (Read Only).
平台的快取儲存路徑
windows: C:/Users/xxxx/AppData/Local/Temp/CompanyName/ProductName
IPone: Application/???/Library/Caches
Android: /data/data/Name/cache
以下是顯示路徑的測試代碼 :
using UnityEngine;
using System.Collections;
public class Example_FilePath : MonoBehaviour {
// Use this for initialization
void Start () {
string Platform = "";
#if UNITY_EDITOR
Platform = "EDITOR";
#elif UNITY_IPHONE
Platform = "IPHONE";
#elif UNITY_ANDROID
Platform = "ANDROID";
#endif
Debug.Log(Platform);
Debug.Log("dataPath: " + Application.dataPath);
Debug.Log("persistentDataPath: " + Application.persistentDataPath);
Debug.Log("streamingAssetsPath: " + Application.streamingAssetsPath);
Debug.Log("temporaryCachePath: " + Application.temporaryCachePath);
}
// Update is called once per frame
void Update () {
}
}
歡迎光臨 ~ Eg 程式筆記的天堂
當你看完此篇文章,如果你覺得文章不錯
可以留下鼓勵的留言~
將是我的撰寫更多相關文章的動力
