Application中的路徑


前提條件

項目工程目錄:E:/Work/cosmosbox/cb-client/

我電腦當前的用戶名:qingqing

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM