查看: 645|回复: 0
打印 上一主题 下一主题

[其他] Unity各种路径总结

[复制链接]

9903

主题

126

听众

7万

积分

首席设计师

Rank: 8Rank: 8

纳金币
53488
精华
316

最佳新人 热心会员 灌水之王 活跃会员 突出贡献 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2015-9-30 19:46:33 |只看该作者 |倒序浏览

Application.persistentDataPath
http://docs.unity3d.com/ScriptRe ... istentDataPath.html
Contains the path to a persistent data directory (Read Only).
设备中的公开目录,根据平台的不同而不同。这里面的文件不会因为App升级而删除;

Application.streamingAssetsPath
http://docs.unity3d.com/ScriptRe ... mingAssetsPath.html
工程目录下面的Assets/StreamingAssets。

Application.temporaryCachePath
http://docs.unity3d.com/ScriptRe ... oraryCachePath.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;  
    }
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-8-13 19:37 , Processed in 0.062185 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部