纳金网

标题: Unity3D如何为资源管理文件加密? [打印本页]

作者: 狂风大尉    时间: 2015-1-31 18:13
标题: Unity3D如何为资源管理文件加密?
Unity允许用户使用AssetBundle.CreateFromMemory从一个 byte[]数组中建立一个AssetBundle的对象。在运行传输解密时,可以用这种加密方法来提高安全性和保护用户建立的资源管理中的内容。
代码如下:
  1. string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
  2. IEnumerator Start () {
  3. // Start a download of the given URL
  4. WWW www = new WWW (url);
  5. // Wait for download to complete
  6. yield return www;
  7. // Get the byte data
  8. byte[] encryptedData = www.bytes;
  9. // Load the TextAsset object
  10. byte[] decryptedData = YourDecryptionMethod(encryptedData);
  11. // Create an AssetBundle from the bytes array
  12. AssetBundle bundle = AssetBundle.CreateFromMemory(decryptedData);
  13. // You can now use your AssetBundle
  14. }
复制代码


作者: hariboot    时间: 2015-1-31 18:53
Thanks for sharing!




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5