parent
efa71c8bb7
commit
5415d95f36
|
@ -78,6 +78,9 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(InitializeParameters parameters)
|
||||
{
|
||||
// 注意:WebGL平台因为网络原因可能会初始化失败!
|
||||
ResetInitializeAfterFailed();
|
||||
|
||||
// 检测初始化参数合法性
|
||||
CheckInitializeParameters(parameters);
|
||||
|
||||
|
@ -127,6 +130,20 @@ namespace YooAsset
|
|||
initializeOperation.Completed += InitializeOperation_Completed;
|
||||
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)
|
||||
{
|
||||
if (_isInitialize)
|
||||
|
|
|
@ -106,6 +106,18 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
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)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
@ -118,8 +130,6 @@ namespace YooAsset
|
|||
if (package.PackageName == packageName)
|
||||
return package;
|
||||
}
|
||||
|
||||
YooLogger.Warning($"Not found assets package : {packageName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue