I took up the task of protecting the content like http://docs.unity3d.com/Manual/protectingcontent.html.
And I implemented a third way: store an AssetBundle itself as a TextAsset, inside another normal AssetBundles.
I export and encode scene. But after loading the text Asset, decode and reconstruct the original Asset - all objects in the scene are losing their scripts (as NGUI and mine).
Export is as follows:
BuildPipeline.BuildStreamedSceneAssetBundle(fightScenes,
assetBundleName,
EditorUserBuildSettings.activeBuildTarget,
BuildOptions.BuildAdditionalStreamedScenes | BuildOptions.UncompressedAssetBundle);
bytes = File.ReadAllBytes(assetBundleName);
bytes = FCryptography.Encode(bytes);
string encodeAssetFileName = “EncodeAsset.bytes”;
FileStream fs = File.Create(encodeAssetFileName);
fs.Write(bytes, 0, bytes.Length);
AssetDatabase.Refresh();
UnityEngine.Object asset = AssetDatabase.LoadMainAssetAtPath(encodeAssetFileName);
BuildPipeline.BuildAssetBundle(asset,
null,
encodeTextAssetFilename,
BuildAssetBundleOptions.UncompressedAssetBundle,
EditorUserBuildSettings.activeBuildTarget);
Import like this:
WWW www = [WWW.LoadFromCacheOrDownload(path](http://WWW.LoadFromCacheOrDownload(path), version);
yield return null;
AssetBundleRequest req = [www.assetBundle.LoadAsync(objName](http://www.assetBundle.LoadAsync(objName), typeof(TextAsset));
yield return req;
byte[ ] decryptedData = FCryptography.Decode(((TextAsset)req.asset).bytes);
AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(decryptedData);
yield return acr;
OnWWWLoaded(acr.assetBundle);