Update YooAssets.cs

检测原生文件加载方法,预防传入无效文件。
pull/21/head
hevinci 2022-07-05 20:07:32 +08:00
parent 63f90e1537
commit 7d5b6504f4
2 changed files with 9 additions and 18 deletions

View File

@ -119,11 +119,6 @@ namespace YooAsset
} }
} }
/// <summary>
/// 错误信息
/// </summary>
public string Error { private set; get; }
private BundleInfo() private BundleInfo()
{ {
@ -136,7 +131,6 @@ namespace YooAsset
RemoteMainURL = mainURL; RemoteMainURL = mainURL;
RemoteFallbackURL = fallbackURL; RemoteFallbackURL = fallbackURL;
EditorAssetPath = string.Empty; EditorAssetPath = string.Empty;
Error = string.Empty;
} }
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath) public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
{ {
@ -146,7 +140,6 @@ namespace YooAsset
RemoteMainURL = string.Empty; RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty; RemoteFallbackURL = string.Empty;
EditorAssetPath = editorAssetPath; EditorAssetPath = editorAssetPath;
Error = string.Empty;
} }
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode) public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
{ {
@ -156,17 +149,6 @@ namespace YooAsset
RemoteMainURL = string.Empty; RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty; RemoteFallbackURL = string.Empty;
EditorAssetPath = 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;
} }
/// <summary> /// <summary>

View File

@ -536,6 +536,15 @@ namespace YooAsset
} }
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); 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) if (_playMode == EPlayMode.EditorSimulateMode)
{ {
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath); RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);