Update bundleInfo

修复原生文件拷贝目录不存导致的加载失败
完善原生文件异步加载接口
This commit is contained in:
hevinci
2022-04-18 15:08:39 +08:00
parent abb75fe858
commit b221b8121a
14 changed files with 214 additions and 155 deletions
@@ -28,7 +28,7 @@ namespace YooAsset
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
{
YooLogger.Warning($"Editor play mode can not get bundle info.");
BundleInfo bundleInfo = new BundleInfo(bundleName, bundleName);
BundleInfo bundleInfo = new BundleInfo(bundleName);
return bundleInfo;
}
string IBundleServices.GetBundleName(string assetPath)
@@ -196,10 +196,9 @@ namespace YooAsset
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
{
// 注意:资源版本号只用于确定下载路径
string sandboxPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Hash);
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
return bundleInfo;
}
@@ -207,36 +206,34 @@ namespace YooAsset
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
{
if (string.IsNullOrEmpty(bundleName))
return new BundleInfo(string.Empty, string.Empty);
return new BundleInfo(string.Empty);
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
{
// 查询沙盒资源
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
{
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
return bundleInfo;
}
// 查询APP资源
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
{
string appLoadPath = PathHelper.MakeStreamingLoadPath(appPatchBundle.Hash);
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, appLoadPath);
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
return bundleInfo;
}
}
// 查询沙盒资源
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
{
string sandboxLoadPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxLoadPath);
return bundleInfo;
}
// 从服务端下载
return ConvertToDownloadInfo(patchBundle);
}
else
{
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
BundleInfo bundleInfo = new BundleInfo(bundleName);
return bundleInfo;
}
}
@@ -42,18 +42,17 @@ namespace YooAsset
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
{
if (string.IsNullOrEmpty(bundleName))
return new BundleInfo(string.Empty, string.Empty);
return new BundleInfo(string.Empty);
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
{
string localPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
BundleInfo bundleInfo = new BundleInfo(patchBundle, localPath);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
return bundleInfo;
}
else
{
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
BundleInfo bundleInfo = new BundleInfo(bundleName);
return bundleInfo;
}
}