diff --git a/Assets/Editor/AutoPack.cs b/Assets/Editor/AutoPack.cs
index 54fbc1f9aa..1813376714 100644
--- a/Assets/Editor/AutoPack.cs
+++ b/Assets/Editor/AutoPack.cs
@@ -241,7 +241,7 @@ public class AutoPack : EditorWindow
ExportAS(i);
ReplaceFromProject(i);
ReplaceConfigAndVersion(i);
- EncryptAB(i);
+ //EncryptAB(i);
GitUpdate(i);
CreateLogFile(i);
StartGradleBuild(i);
@@ -250,7 +250,7 @@ public class AutoPack : EditorWindow
case 1: // 只替换AB
ReplaceFromAB(i);
ReplaceConfigAndVersion(i);
- EncryptAB(i);
+ //EncryptAB(i);
GitUpdate(i);
CreateLogFile(i);
StartGradleBuild(i);
diff --git a/Assets/LuaFramework/Scripts/Common/LuaLoader.cs b/Assets/LuaFramework/Scripts/Common/LuaLoader.cs
index c4390a7a55..89fe64095d 100644
--- a/Assets/LuaFramework/Scripts/Common/LuaLoader.cs
+++ b/Assets/LuaFramework/Scripts/Common/LuaLoader.cs
@@ -46,8 +46,7 @@ namespace GameLogic {
string url = Util.DataPath + bundleName.ToLower();
if (File.Exists(url))
{
- //AssetBundle bundle = AssetBundle.LoadFromFile(url, 0, GameLogic.AppConst.EncyptBytesLength);
- AssetBundle bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(url), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
+ AssetBundle bundle = MEncyptUtil.LoadAssetBundle(url, AppConst.EncyptKey, AppConst.EncyptBytesLength);
if (bundle != null)
{
bundleName = bundleName.Replace("lua/", "").Replace(".unity3d", "");
diff --git a/Assets/LuaFramework/Scripts/Utility/MEncyptUtil.cs b/Assets/LuaFramework/Scripts/Utility/MEncyptUtil.cs
index b100324b09..d956877009 100644
--- a/Assets/LuaFramework/Scripts/Utility/MEncyptUtil.cs
+++ b/Assets/LuaFramework/Scripts/Utility/MEncyptUtil.cs
@@ -77,7 +77,33 @@ namespace GameLogic {
File.WriteAllBytes(path, rb);
}
+ public static AssetBundle LoadAssetBundle(string path, string encryptKey, ulong offset)
+ {
+ AssetBundle ab;
+ if (AppConst.PlatformPath.Equals("Android"))
+ {
+ ab = AssetBundle.LoadFromFile(path, 0, offset);
+ }
+ else
+ {
+ ab = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), encryptKey, offset));
+ }
+ return ab;
+ }
+ public static AssetBundleCreateRequest LoadAssetBundleAsync(string path, string encryptKey, ulong offset)
+ {
+ AssetBundleCreateRequest ab;
+ if (AppConst.PlatformPath.Equals("Android"))
+ {
+ ab = AssetBundle.LoadFromFileAsync(path, 0, offset);
+ }
+ else
+ {
+ ab = AssetBundle.LoadFromMemoryAsync(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), encryptKey, offset));
+ }
+ return ab;
+ }
//[MenuItem("Build/TEST")]
//static void load()
//{
diff --git a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs
index 8dc93a2cbb..0dfd106546 100644
--- a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs
+++ b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs
@@ -369,8 +369,8 @@ namespace ResMgr
#if XNCS
XNCSUtils.BeginSample("LoadAssetBundle:{0}",path);
#endif
- assetBundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
- //assetBundle = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
+
+ assetBundle = GameLogic.MEncyptUtil.LoadAssetBundle(fullPath, GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength);
#if XNCS
XNCSUtils.EndSample();
#endif
@@ -398,8 +398,8 @@ namespace ResMgr
{
if (BaseLogger.isDebug) BaseLogger.LogFormat("LoadAssetBundleAsyn:{0}", path);
abLoaderState = ABLoaderState.Loading;
- //AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
- AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
+
+ AssetBundleCreateRequest request = GameLogic.MEncyptUtil.LoadAssetBundleAsync(fullPath, GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength);
while (!request.isDone)
{
progress = request.progress;
diff --git a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs
index 48bf3f786e..9e326c7f30 100644
--- a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs
+++ b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs
@@ -180,8 +180,7 @@ namespace ResMgr
string path = string.Format("LZMA/ResConfigs").ToLower() + ResConfig.ABExtName;
#endif
string fullPath = PathHelper.GetFullPath (path);
- //AssetBundle ab = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
- AssetBundle ab = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
+ AssetBundle ab = GameLogic.MEncyptUtil.LoadAssetBundle(path, GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength);
ResPathConfig = ab.LoadAsset("ResourcePathConfig");
ab.Unload(true);
}
diff --git a/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs b/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs
index 1d18b23783..dfacfed6f8 100644
--- a/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs
+++ b/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs
@@ -519,7 +519,7 @@ namespace ResUpdate
///
List GetNewResourceFiles()
{
- AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.PersistentDataPath + UpdateConfigs.FILES);//, 0, AppConst.EncyptBytesLength);
+ AssetBundle bundle = MEncyptUtil.LoadAssetBundle(UpdateConfigs.PersistentDataPath + UpdateConfigs.FILES, "", 0);
ResourceFiles files = bundle.LoadAsset("game");
List list = files.files;
bundle.Unload(true);
@@ -532,7 +532,7 @@ namespace ResUpdate
///
List GetStreamResourceFiles()
{
- AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.StreamPath + UpdateConfigs.FILES);//, 0, AppConst.EncyptBytesLength);
+ AssetBundle bundle = MEncyptUtil.LoadAssetBundle(UpdateConfigs.StreamPath + UpdateConfigs.FILES, "", 0);
if (bundle != null)
{
ResourceFiles files = bundle.LoadAsset("game");
diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs
index 3a8d87dbdd..d9190e170e 100644
--- a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs
+++ b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs
@@ -58,8 +58,7 @@ namespace GameEditor.FrameTool
//遍历内部unity3d数据
public static List GetFilesList(string filesPath, string encryptKey = null)
{
- //UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromFile(filesPath + UpdateConfigs.FILES);
- UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(filesPath + UpdateConfigs.FILES), encryptKey, 0));
+ UnityEngine.AssetBundle bundle = GameLogic.MEncyptUtil.LoadAssetBundle(filesPath + UpdateConfigs.FILES, encryptKey, 0);
ResourceFiles files = bundle.LoadAsset("game");
bundle.Unload(true);
return files.files;
@@ -342,7 +341,7 @@ namespace GameEditor.FrameTool
Directory.CreateDirectory(dirName);
}
File.Copy(local_files_path + file, cpPath + file, true);
- if (local_version.EncyptKey != null && local_version.EncyptKey != "")
+ if (local_version.EncyptKey != null && local_version.EncyptKey != "" && AppConst.PlatformPath.Equals("IOS"))
{
MEncyptUtil.EncyptAB(cpPath + file, local_version.EncyptKey);
}
diff --git a/Assets/Scripts/GameInit/GameStart.cs b/Assets/Scripts/GameInit/GameStart.cs
index 0dba3944ba..499bac181c 100644
--- a/Assets/Scripts/GameInit/GameStart.cs
+++ b/Assets/Scripts/GameInit/GameStart.cs
@@ -89,8 +89,7 @@ public class GameStart : MonoBehaviour
{
path = AppConst.StreamPath + splashFilePath;
}
- //bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
- bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
+ bundle = MEncyptUtil.LoadAssetBundle(path, AppConst.EncyptKey, AppConst.EncyptBytesLength);
GameObject gameObj = bundle.LoadAsset("SplashPanel");
GameObject gameObj2 = Instantiate(gameObj, Vector3.zero, Quaternion.identity);
Image image = gameObj2.transform.Find("Canvas/image").GetComponent();
diff --git a/Assets/Scripts/GameInit/UpdateManager.cs b/Assets/Scripts/GameInit/UpdateManager.cs
index d832692e0e..ba79232991 100644
--- a/Assets/Scripts/GameInit/UpdateManager.cs
+++ b/Assets/Scripts/GameInit/UpdateManager.cs
@@ -125,8 +125,7 @@ namespace GameLogic {
{
path = AppConst.StreamPath + updateFilePath;
}
- //bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
- bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
+ bundle = MEncyptUtil.LoadAssetBundle(path, AppConst.EncyptKey, AppConst.EncyptBytesLength);
if (bundle == null)
{
XDebug.Log.error(string.Format("{0} 不存在,请检查", path ));