1. 程式人生 > >unity Application路徑

unity Application路徑

PersistentDataPath

Application.persistentDataPath 持久資料路徑,APP更新時不會刪除此資料 例:C:/Users/qingqing/AppData/LocalLow/Cosmosbox/

最後一位的目錄名為PlayerSettings中設定的CompanyName

image

在Windows平臺可能因為使用者名稱為非英文字條而出現其它麻煩,可以設定為 xxx/Library/UnityWinPersistentDataPath

複製程式碼

public static string GetAppDataPath()
{
    // Windows 時使用特定的目錄,避免中文User的存在
    if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer)
    {
        string dataPath = Application.dataPath + "/../Library/UnityWinPersistentDataPath";
        if (!Directory.Exists(dataPath))
            Directory.CreateDirectory(dataPath);
        return dataPath;
    }

    return Application.persistentDataPath;
}

複製程式碼

文件:http://wiki.ceeger.com/script:unityengine:classes:application:application.persistentdatapath

 

dataPath

Application.dataPath 資料路徑(Assets目錄)  例:E:/Work/cosmosbox/cb-client/Assets

詳細:http://wiki.ceeger.com/script:unityengine:classes:application:application.datapath?s[]=application

 

streamingAssetsPath

Application.streamingAssetsPath (Assets/StreamingAssets目錄),AssetBundle一般存放在此目錄下,可以通過www讀取 例:E:/Work/cosmosbox/cb-client/Assets/StreamingAssets

Android:jar:file://+Application.dataPath+string.Format("!/assets/{0}/", ResourceDirName)

Unity Editor:file:///

文件:http://wiki.ceeger.com/script:unityengine:classes:application:application.streamingassetspath

 

temporaryCachePath

Application.temporaryCachePath 作業系統的臨時快取目錄 ,例: Z:/TEMP/Cosmosbox/ [我的電腦把快取檔案設定在Z盤]

image

文件:http://wiki.ceeger.com/script:unityengine:classes:application:application.temporarycachepath?s[]=application