parent
efa71c8bb7
commit
5415d95f36
|
@ -78,6 +78,9 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(InitializeParameters parameters)
|
public InitializationOperation InitializeAsync(InitializeParameters parameters)
|
||||||
{
|
{
|
||||||
|
// 注意:WebGL平台因为网络原因可能会初始化失败!
|
||||||
|
ResetInitializeAfterFailed();
|
||||||
|
|
||||||
// 检测初始化参数合法性
|
// 检测初始化参数合法性
|
||||||
CheckInitializeParameters(parameters);
|
CheckInitializeParameters(parameters);
|
||||||
|
|
||||||
|
@ -127,6 +130,20 @@ namespace YooAsset
|
||||||
initializeOperation.Completed += InitializeOperation_Completed;
|
initializeOperation.Completed += InitializeOperation_Completed;
|
||||||
return initializeOperation;
|
return initializeOperation;
|
||||||
}
|
}
|
||||||
|
private void ResetInitializeAfterFailed()
|
||||||
|
{
|
||||||
|
if(_isInitialize && _initializeStatus == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
_isInitialize = false;
|
||||||
|
_initializeStatus = EOperationStatus.None;
|
||||||
|
_initializeError = string.Empty;
|
||||||
|
_bundleServices = null;
|
||||||
|
_assetSystemImpl = null;
|
||||||
|
_editorSimulateModeImpl = null;
|
||||||
|
_offlinePlayModeImpl = null;
|
||||||
|
_hostPlayModeImpl = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
private void CheckInitializeParameters(InitializeParameters parameters)
|
private void CheckInitializeParameters(InitializeParameters parameters)
|
||||||
{
|
{
|
||||||
if (_isInitialize)
|
if (_isInitialize)
|
||||||
|
|
|
@ -106,6 +106,18 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageName">资源包名称</param>
|
/// <param name="packageName">资源包名称</param>
|
||||||
public static AssetsPackage GetAssetsPackage(string packageName)
|
public static AssetsPackage GetAssetsPackage(string packageName)
|
||||||
|
{
|
||||||
|
var package = TryGetAssetsPackage(packageName);
|
||||||
|
if (package == null)
|
||||||
|
YooLogger.Warning($"Not found assets package : {packageName}");
|
||||||
|
return package;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取资源包
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageName">资源包名称</param>
|
||||||
|
public static AssetsPackage TryGetAssetsPackage(string packageName)
|
||||||
{
|
{
|
||||||
if (_isInitialize == false)
|
if (_isInitialize == false)
|
||||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||||
|
@ -118,8 +130,6 @@ namespace YooAsset
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Warning($"Not found assets package : {packageName}");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue