Application中的路径
本文为作者原创,转载请注明出处:https://www.cnblogs.com/zhaoqingqing/p/4983777.html
前提条件#
项目工程目录:E:/Work/cosmosbox/cb-client/
我电脑当前的用户名:qingqing
PersistentDataPath#
Application.persistentDataPath 持久数据路径,APP更新时不会删除此数据 例:C:/Users/qingqing/AppData/LocalLow/Cosmosbox/
最后一位的目录名为PlayerSettings中设置的CompanyName
在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盘]
本文版权归作者和博客园共有,欢迎转载,转载之后请务必在文章明显位置标出原文链接和作者,谢谢。
如果本文对您有帮助,请点击【推荐】您的赞赏将鼓励我继续创作!想跟我一起进步么?那就【关注】我吧。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 10亿数据,如何做迁移?
· 推荐几款开源且免费的 .NET MAUI 组件库
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 易语言 —— 开山篇
· Trae初体验