UntiyAssetBundle加密可行性分析

本文探讨了Unity中AssetBundle加密的可行性,分析了异或加密方式,指出其导致的额外内存消耗和性能下降问题。测试结果显示,加密加载相比原方式增加约50%的同步加载时间和36%的异步加载时间。考虑到AssetBundle.LoadFromStream(Async)的限制,特别是Android平台的限制,文章结论是目前不建议对AssetBundle进行加密处理。
摘要由CSDN通过智能技术生成

背景

我们发现市面上有其他游戏使用公司的游戏资源,现有的游戏资源并未加密处理。为了提高破解的门槛,想对资源进行加密处理。

异或加密方式可行性分析

  1. 为什么使用异或加密
    采取异或加密的原因在于加解密方式简单,解密性能开销较低,另外也不会改变文件大小。
  2. 异或加密带来的AssetBundle加载api调用修改
    使用加密的AssetBundle需要先把文件读取到byte数组,再对byte数组进行异或解密处理,最后再调用
    原来项目使用AssetBundle.LoadFromMemory/AssetBundle.LoadFromMemoryAsync api进行加载。
  3. LoadFromFile/LoadFromFileAsync与LoadFromMemory/LoadFromMemoryAsync进行对比
    3.1 官方信息
    AssetBundle.LoadFromFile(Async)

AssetBundle.LoadFromFile is a highly-efficient API intended for loading uncompressed or LZ4-compressed AssetBundle from local storage, such as a hard disk or an SD card.
On desktop standalone, console, and mobile platforms, the API will only load the AssetBundle’s header, and will leave the remaining data on disk. The AssetBundle’s Objects will be loaded on-demand as loading methods (e.g. AssetBundle.Load) are called or as their InstanceIDs are dereferenced. No excess memory will be consumed in this scenario. In the Unity Editor, the API will load the entire AssetBundle into memory, as if the bytes were read off disk and AssetBundle.LoadFromMemoryAsync was used. This API can cause memory spikes to appear during AssetBundle loading if the project is profiled in the Unity Editor. This should not affect performance on-device and these spikes should be re-tested on-device before taking remedial action.
Note: On Android devices with

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值