英文:
Storing files in PersistentDataPath without going through StreamingAssets on Android and iOS
问题
我已经创建了一个构建管道脚本,允许我构建我的应用程序适用于 Android
和 iOS
。
我不知道如何管理远程更新的资产。
我目前的做法
我有大约 100 个文件,每个文件大小为 20MB。
我能够在构建时将这些文件复制到 StreamingAssets
。
因为 StreamingAssets
是只读的,所以当我想使用一个资产时,我将其复制到 persistentDataPath
,检查远程服务器上的文件是否有新版本,如果有 - 下载它。然后我从 persistentDataPath
读取新内容...
我的问题
当我发布应用程序时,它已经在 StreaminAssets
中有了这些文件,然后我在 persistentData
中复制了一份,这使得我的应用程序在设备上占用了两倍的空间。
是否有一种方法可以直接将文件添加到 persistentDataPath
中构建游戏,而不需要经过 StreamingAssets
路径?
英文:
I've created a build pipeline script, which allows me to build my app for Android
and iOS
.
I don't know how to manage assets, which remotely update.
What I do atm
I have about 100 files, each one is 20MB in size.
I am able to copy these files to StreamingAssets
at build time.
Because StreamingAssets
is read only
, when I want to use an asset, I copy it to persistentDataPath
, check if there is a new version of the file on my remote server and if yes - download it. I then read the fresh content from the persistentDataPath
...
My problem
When I ship the app it already has the files in StreaminAssets
, I then duplicate them in persistentData
, which makes my app take twice as much space on the device.
Is there a way to build the game with the files added to persistentDataPath
directly without going through the StreamingAssets
path?
答案1
得分: 0
为什么不直接跳过关于StreamingAssets
的部分?
=> 检查
- 文件是否存在于persistentDataPath中缺失
- 或者服务器上有更新版本
=> 在这两种情况下下载(并替换)
当你第一次打开应用时,可能会花费更长的时间,但这实际上是大多数应用程序现在的工作方式。
如果你问的是在安装应用程序时直接立即解压文件到persistentDataPath
中的方法:
我认为没有更直接的方法了。
如果你希望应用程序从一开始就包含所有内容,那么是的,它需要全部打包到APK中,后来就不能删除内容了。
或者,你也可以查看Addressables,它也支持缓存。
英文:
Why not simply entirely skip the part about StreamingAssets
?
=> Check if
- file exists is missing in persitentDataPath
- or there is a newer version on your server
=> In both cases download (and replace)
Sure it takes a bit longer the first time you open the app, but this is actually how most apps work nowadays.
If you are asking about directly and immediately unpacking files into persistentDataPath
when installing the app:
I don't think there is a more direct way for this.
If you want the app to contain all content already from the beginning, well then yes, it needs to be all packed into the APK which you can't remove content from later on.
Alternatively you could also give Addressables a look which supports caching as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论