Unity3D学习笔记之AssetBundle包加密

来源:互联网 发布:谷歌人工智能 开源 编辑:程序博客网 时间:2024/06/05 15:11

保护资源管理文件的相关内容 Unity允许用户使用AssetBundle.CreateFromMemory从一个 byte[]数组中建立一个AssetBundle的对象。在运行传输解密时,可以用这种加密方法来提高安全性和保护用户建立的资源管理中的内容。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
stringurl = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
// Start a download of the given URL
WWW www = newWWW (url);
 
// Wait for download to complete
yieldreturn www;
 
// Get the byte data
byte[] encryptedData = www.bytes;
 
// Load the TextAsset object
byte[] decryptedData = YourDecryptionMethod(encryptedData);
 
// Create an AssetBundle from the bytes array
AssetBundle bundle = AssetBundle.CreateFromMemory(decryptedData);
 
// You can now use your AssetBundle
}
原创粉丝点击