diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs
index 40aeda1..f003613 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs
@@ -20,7 +20,8 @@ namespace YooAsset
private bool _isUnloadSafe = true;
private string _packageName;
private bool _simulationOnEditor;
- private int _loadingMaxNumber;
+ public int LoadingMaxNumber { private set; get; }
+ public int DownloadFailedTryAgain { private set; get; }
public IDecryptionServices DecryptionServices { private set; get; }
public IBundleServices BundleServices { private set; get; }
@@ -29,11 +30,13 @@ namespace YooAsset
/// 初始化
/// 注意:在使用AssetSystem之前需要初始化
///
- public void Initialize(string packageName, bool simulationOnEditor, int loadingMaxNumber, IDecryptionServices decryptionServices, IBundleServices bundleServices)
+ public void Initialize(string packageName, bool simulationOnEditor, int loadingMaxNumber, int downloadFailedTryAgain,
+ IDecryptionServices decryptionServices, IBundleServices bundleServices)
{
_packageName = packageName;
_simulationOnEditor = simulationOnEditor;
- _loadingMaxNumber = loadingMaxNumber;
+ LoadingMaxNumber = loadingMaxNumber;
+ DownloadFailedTryAgain = downloadFailedTryAgain;
DecryptionServices = decryptionServices;
BundleServices = bundleServices;
}
@@ -63,7 +66,7 @@ namespace YooAsset
}
else
{
- if (loadingCount < _loadingMaxNumber)
+ if (loadingCount < LoadingMaxNumber)
provider.Update();
if (provider.IsDone == false)
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs
index b113421..9de9906 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs
@@ -81,7 +81,7 @@ namespace YooAsset
// 1. 从服务器下载
if (_steps == ESteps.Download)
{
- int failedTryAgain = int.MaxValue;
+ int failedTryAgain = Impl.DownloadFailedTryAgain;
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload;
}
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs
index 0b21ebd..f3fedb5 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs
@@ -70,7 +70,7 @@ namespace YooAsset
// 1. 从服务器下载
if (_steps == ESteps.Download)
{
- int failedTryAgain = int.MaxValue;
+ int failedTryAgain = Impl.DownloadFailedTryAgain;
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload;
}
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs
index 4aa615f..b7ee11a 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs
@@ -63,7 +63,7 @@ namespace YooAsset
// 1. 下载远端文件
if (_steps == ESteps.Download)
{
- int failedTryAgain = int.MaxValue;
+ int failedTryAgain = Impl.DownloadFailedTryAgain;
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload;
}
diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs
index c98565a..b5513d6 100644
--- a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs
+++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs
@@ -61,7 +61,7 @@ namespace YooAsset
// 1. 下载远端文件
if (_steps == ESteps.Download)
{
- int failedTryAgain = int.MaxValue;
+ int failedTryAgain = Impl.DownloadFailedTryAgain;
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload;
}
diff --git a/Assets/YooAsset/Runtime/InitializeParameters.cs b/Assets/YooAsset/Runtime/InitializeParameters.cs
index d543ca0..077b78d 100644
--- a/Assets/YooAsset/Runtime/InitializeParameters.cs
+++ b/Assets/YooAsset/Runtime/InitializeParameters.cs
@@ -43,6 +43,11 @@ namespace YooAsset
/// 注意:默认值为MaxValue
///
public int AssetLoadingMaxNumber = int.MaxValue;
+
+ ///
+ /// 下载失败尝试次数
+ ///
+ public int DownloadFailedTryAgain = int.MaxValue;
}
///
diff --git a/Assets/YooAsset/Runtime/PatchSystem/ManifestTools.cs b/Assets/YooAsset/Runtime/PatchSystem/ManifestTools.cs
index 70ccc60..107bce9 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/ManifestTools.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/ManifestTools.cs
@@ -74,6 +74,14 @@ namespace YooAsset
}
}
+ ///
+ /// 反序列化(JSON文件)
+ ///
+ public static PackageManifest DeserializeFromJson(string jsonContent)
+ {
+ return JsonUtility.FromJson(jsonContent);
+ }
+
///
/// 反序列化(二进制文件)
///
diff --git a/Assets/YooAsset/Runtime/ResourcePackage.cs b/Assets/YooAsset/Runtime/ResourcePackage.cs
index 8091bc3..879bdad 100644
--- a/Assets/YooAsset/Runtime/ResourcePackage.cs
+++ b/Assets/YooAsset/Runtime/ResourcePackage.cs
@@ -87,7 +87,9 @@ namespace YooAsset
var editorSimulateModeImpl = new EditorSimulateModeImpl();
_bundleServices = editorSimulateModeImpl;
_playModeServices = editorSimulateModeImpl;
- _assetSystemImpl.Initialize(PackageName, true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
+ _assetSystemImpl.Initialize(PackageName, true,
+ parameters.AssetLoadingMaxNumber, parameters.DownloadFailedTryAgain,
+ parameters.DecryptionServices, _bundleServices);
var initializeParameters = parameters as EditorSimulateModeParameters;
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulateManifestFilePath);
@@ -97,7 +99,9 @@ namespace YooAsset
var offlinePlayModeImpl = new OfflinePlayModeImpl();
_bundleServices = offlinePlayModeImpl;
_playModeServices = offlinePlayModeImpl;
- _assetSystemImpl.Initialize(PackageName, false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
+ _assetSystemImpl.Initialize(PackageName, false,
+ parameters.AssetLoadingMaxNumber, parameters.DownloadFailedTryAgain,
+ parameters.DecryptionServices, _bundleServices);
var initializeParameters = parameters as OfflinePlayModeParameters;
initializeOperation = offlinePlayModeImpl.InitializeAsync(PackageName, initializeParameters.LocationToLower);
@@ -107,7 +111,9 @@ namespace YooAsset
var hostPlayModeImpl = new HostPlayModeImpl();
_bundleServices = hostPlayModeImpl;
_playModeServices = hostPlayModeImpl;
- _assetSystemImpl.Initialize(PackageName, false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
+ _assetSystemImpl.Initialize(PackageName, false,
+ parameters.AssetLoadingMaxNumber, parameters.DownloadFailedTryAgain,
+ parameters.DecryptionServices, _bundleServices);
var initializeParameters = parameters as HostPlayModeParameters;
initializeOperation = hostPlayModeImpl.InitializeAsync(
@@ -187,6 +193,11 @@ namespace YooAsset
parameters.AssetLoadingMaxNumber = 1;
YooLogger.Warning($"{nameof(parameters.AssetLoadingMaxNumber)} minimum value is 1");
}
+ if (parameters.DownloadFailedTryAgain < 1)
+ {
+ parameters.DownloadFailedTryAgain = 1;
+ YooLogger.Warning($"{nameof(parameters.DownloadFailedTryAgain)} minimum value is 1");
+ }
}
private void InitializeOperation_Completed(AsyncOperationBase op)
{
@@ -228,7 +239,7 @@ namespace YooAsset
DebugCheckInitialize();
return _playModeServices.PreDownloadContentAsync(packageVersion, timeout);
}
-
+
///
/// 清理包裹未使用的缓存文件
///