From 7d5b6504f4545af4daed8469c21d0477caaf8235 Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 5 Jul 2022 20:07:32 +0800 Subject: [PATCH] Update YooAssets.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 检测原生文件加载方法,预防传入无效文件。 --- .../YooAsset/Runtime/PatchSystem/BundleInfo.cs | 18 ------------------ Assets/YooAsset/Runtime/YooAssets.cs | 9 +++++++++ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs b/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs index ae18bfc..4032cf5 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs @@ -119,11 +119,6 @@ namespace YooAsset } } - /// - /// 错误信息 - /// - public string Error { private set; get; } - private BundleInfo() { @@ -136,7 +131,6 @@ namespace YooAsset RemoteMainURL = mainURL; RemoteFallbackURL = fallbackURL; EditorAssetPath = string.Empty; - Error = string.Empty; } public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath) { @@ -146,7 +140,6 @@ namespace YooAsset RemoteMainURL = string.Empty; RemoteFallbackURL = string.Empty; EditorAssetPath = editorAssetPath; - Error = string.Empty; } public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode) { @@ -156,17 +149,6 @@ namespace YooAsset RemoteMainURL = string.Empty; RemoteFallbackURL = string.Empty; EditorAssetPath = string.Empty; - Error = string.Empty; - } - public BundleInfo(string error) - { - _patchBundle = null; - LoadMode = ELoadMode.None; - BundleName = string.Empty; - RemoteMainURL = string.Empty; - RemoteFallbackURL = string.Empty; - EditorAssetPath = string.Empty; - Error = error; } /// diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 8b2f551..0fa3b4e 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -536,6 +536,15 @@ namespace YooAsset } BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); + if (bundleInfo.IsRawFile == false) + { + string error = $"Cannot load asset bundle file using {nameof(GetRawFileAsync)} interfaces !"; + YooLogger.Warning(error); + RawFileOperation operation = new CompletedRawFileOperation(error, copyPath); + OperationSystem.StartOperaiton(operation); + return operation; + } + if (_playMode == EPlayMode.EditorSimulateMode) { RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);