From 89cc5691cf552d76c9bdc1d69328517dfa3a10ed Mon Sep 17 00:00:00 2001 From: Liang Zhao Date: Wed, 19 Jan 2022 11:40:37 +0800 Subject: [PATCH] =?UTF-8?q?AssetBundle.LoadFromFileAsync=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BB=8E=E4=BA=91=E7=AB=AF=E4=B8=8B=E8=BD=BDAB=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E4=BD=BF=E7=94=A8Unity=202019.4.29f1c109?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + Assets/Editor/Pack/PackRun.cs | 4 +- Assets/Src/Core/Resource/AssetsMgr.cs | 54 ++++++++++++--------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index a72dab523..80754fc46 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,5 @@ Assets/Plugins/SDKBridge* Build/BuildDependenceResource/CurPackEnv.ini Assets/Plugins/VuplexWebViewChromium/log* assetbundleBak* +CustomCloudAssets* +_win64* diff --git a/Assets/Editor/Pack/PackRun.cs b/Assets/Editor/Pack/PackRun.cs index b17607f9f..e0793acca 100644 --- a/Assets/Editor/Pack/PackRun.cs +++ b/Assets/Editor/Pack/PackRun.cs @@ -344,7 +344,9 @@ namespace Pack [InitializeOnLoadMethod] private static void RegisterBuildPlayerHandler() { - BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler); + // TODO: UNITY + // allow Build button in Build Settings window + // BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler); EditorApplication.quitting += OnQuitting; } diff --git a/Assets/Src/Core/Resource/AssetsMgr.cs b/Assets/Src/Core/Resource/AssetsMgr.cs index 424a738de..f2e4cacaf 100644 --- a/Assets/Src/Core/Resource/AssetsMgr.cs +++ b/Assets/Src/Core/Resource/AssetsMgr.cs @@ -490,10 +490,12 @@ public class AssetsMgr : SingletonMono string assetbundleName = AssetsObscureUtil.GetABFileName("assetbundle"); ulong offset = AssetsObscureUtil.GetABOffset(assetbundleName); path = string.Format("{0}{1}", FileSystem.LocalDocumentPath, assetbundleName); + #if !UNITY_INSTANTGAME if (!FileSystem.Exists(path)) { path = string.Format("{0}{1}", FileSystem.LocalPackagePath, assetbundleName); } + #endif var assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); yield return assetBundleCreateRequest; var assetBundleRequest = assetBundleCreateRequest.assetBundle.LoadAssetAsync("AssetBundleManifest"); @@ -523,10 +525,12 @@ public class AssetsMgr : SingletonMono mResidentAssetBundleList.Add(shaderName); string path = string.Format("{0}{1}", FileSystem.LocalDocumentPath, shaderName); + #if !UNITY_INSTANTGAME if (!FileSystem.Exists(path)) { path = string.Format("{0}{1}", FileSystem.LocalPackagePath, shaderName); } + #endif AssetBundleCreateRequest shaderABCreateRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); yield return shaderABCreateRequest; AssetBundle shaderAB = shaderABCreateRequest.assetBundle; @@ -708,15 +712,13 @@ public class AssetsMgr : SingletonMono string path = string.Format("{0}{1}", FileSystem.LocalDocumentPath, depABName); ulong depOffset = AssetsObscureUtil.GetABOffset(depABName); - if (FileSystem.Exists(path)) - { - abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); - } - else + #if !UNITY_INSTANTGAME + if (!FileSystem.Exists(path)) { path = string.Format("{0}{1}", FileSystem.LocalPackagePath, depABName); - abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); } + #endif + abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); syncReqDict.Add(depABName, abRequest); mCurLoadingBundleDic.Add(depABName, new LoadTask(depABName)); } @@ -736,15 +738,13 @@ public class AssetsMgr : SingletonMono //加载场景ab string sceneABPath = FileSystem.LocalDocumentPath + sceneABName; - if (FileSystem.Exists(sceneABPath)) - { - abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); - } - else + #if !UNITY_INSTANTGAME + if (!FileSystem.Exists(sceneABPath)) { sceneABPath = FileSystem.LocalPackagePath + sceneABName; - abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); } + #endif + abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); yield return abRequest; Bundle bundle = new Bundle(abRequest.assetBundle, levelName); mBundlesLoaded.Add(levelName, bundle); @@ -797,15 +797,13 @@ public class AssetsMgr : SingletonMono string path = FileSystem.LocalDocumentPath + depABName; ulong depOffset = AssetsObscureUtil.GetABOffset(depABName); - if (FileSystem.Exists(path)) - { - abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); - } - else + #if !UNITY_INSTANTGAME + if (!FileSystem.Exists(path)) { path = FileSystem.LocalPackagePath + depABName; - abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); } + #endif + abRequest = AssetBundle.LoadFromFileAsync(path, 0, depOffset); syncReqDict.Add(depABName, abRequest); mCurLoadingBundleDic.Add(depABName, new LoadTask(depABName)); } @@ -825,15 +823,13 @@ public class AssetsMgr : SingletonMono //加载场景ab string sceneABPath = FileSystem.LocalDocumentPath + sceneABName; - if (FileSystem.Exists(sceneABPath)) - { - abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); - } - else + #if !UNITY_INSTANTGAME + if (!FileSystem.Exists(sceneABPath)) { sceneABPath = FileSystem.LocalPackagePath + sceneABName; - abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); } + #endif + abRequest = AssetBundle.LoadFromFileAsync(sceneABPath, 0, offset); yield return abRequest; Bundle bundle = new Bundle(abRequest.assetBundle, levelName); mBundlesLoaded.Add(levelName, bundle); @@ -1628,15 +1624,13 @@ public class AssetsMgr : SingletonMono { string path = string.Format("{0}{1}", FileSystem.LocalDocumentPath, bundleName); ulong offset = AssetsObscureUtil.GetABOffset(bundleName); - if (FileSystem.Exists(path)) - { - abRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); - } - else + #if !UNITY_INSTANTGAME + if (!FileSystem.Exists(path)) { path = string.Format("{0}{1}", FileSystem.LocalPackagePath, bundleName); - abRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); } + #endif + abRequest = AssetBundle.LoadFromFileAsync(path, 0, offset); } catch (Exception e) {