Application.persistentDataPath
http://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html
Contains the path to a persistent data directory (Read Only).
设备中的公开目录,根据平台的不同而不同。这里面的文件不会因为App升级而删除;
Application.streamingAssetsPath
http://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html
工程目录下面的Assets/StreamingAssets。
Application.temporaryCachePath
http://docs.unity3d.com/ScriptReference/Application-temporaryCachePath.html
Contains the path to a temporary data / cache directory (Read Only).
设备的临时存储路径。
Application.dataPath
http://docs.unity3d.com/ScriptReference/Application-dataPath.html
游戏数据的存储路径:
Contains the path to the game data folder (Read Only).
The value depends on which platform you are running on:
Unity Editor: <path to project folder>/Assets
Mac player: <path to player app bundle>/Contents
iPhone player: <path to player app bundle>/<AppName.app>/Data
Win player: <path to executablename_Data folder>
Web player: The absolute url to the player data file folder (without the actual data file name)
Flash: The absolute url to the player data file folder (without the actual data file name)
Note that the string returned on a PC will use a forward slash as a folder separator.
参考代码:
public static string GetStreamingFilePath( string filename) { string path = ""; if ( Application.platform == RuntimePlatform .OSXEditor || Application.platform == RuntimePlatform .OSXPlayer || Application.platform == RuntimePlatform .WindowsEditor || Application.platform == RuntimePlatform .WindowsPlayer) path = Application.dataPath + "/StreamingAssets/" + filename; else if ( Application.platform == RuntimePlatform .IPhonePlayer) path = Application.dataPath + "/Raw/" + filename; else if ( Application.platform == RuntimePlatform .Android) path = "jar:file://" + Application .dataPath + "!/assets/" + filename; else path = Application.dataPath + "/config/" + filename; return path; } public static string GetPersistentFilePath( string filename) { string filepath; if ( Application.platform == RuntimePlatform .OSXEditor || Application.platform == RuntimePlatform .OSXPlayer || Application.platform == RuntimePlatform .WindowsEditor || Application.platform == RuntimePlatform .WindowsPlayer) filepath = Application.dataPath + "/StreamingAssets/" + filename; else if ( Application.platform == RuntimePlatform .IPhonePlayer || Application.platform == RuntimePlatform .Android) filepath = Application.persistentDataPath + "/" + filename; else { filepath = Application.persistentDataPath + "/" + filename; } #if UNITY_IPHONE iPhone.SetNoBackupFlag(filepath); #endif return filepath; }
文档信息