refactor : 重构代码

This commit is contained in:
何冠峰
2026-01-17 18:44:48 +08:00
parent e10888de93
commit 0a1c81faf1
75 changed files with 219 additions and 197 deletions

View File

@@ -36,7 +36,7 @@ namespace YooAsset
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback) public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{ {
if (messageID == Guid.Empty) if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !"); throw new ArgumentException("messageID is empty.");
if (_messageCallbacks.ContainsKey(messageID) == false) if (_messageCallbacks.ContainsKey(messageID) == false)
_messageCallbacks.Add(messageID, callback); _messageCallbacks.Add(messageID, callback);
@@ -49,7 +49,7 @@ namespace YooAsset
public void Send(Guid messageID, byte[] data) public void Send(Guid messageID, byte[] data)
{ {
if (messageID == Guid.Empty) if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !"); throw new ArgumentException("messageID is empty.");
// 接收对方的消息 // 接收对方的消息
RemotePlayerConnection.Instance.HandleEditorMessage(messageID, data); RemotePlayerConnection.Instance.HandleEditorMessage(messageID, data);

View File

@@ -36,7 +36,7 @@ namespace YooAsset
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback) public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{ {
if (messageID == Guid.Empty) if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !"); throw new ArgumentException("messageID is empty.");
if (_messageCallbacks.ContainsKey(messageID) == false) if (_messageCallbacks.ContainsKey(messageID) == false)
_messageCallbacks.Add(messageID, callback); _messageCallbacks.Add(messageID, callback);
@@ -49,7 +49,7 @@ namespace YooAsset
public void Send(Guid messageID, byte[] data) public void Send(Guid messageID, byte[] data)
{ {
if (messageID == Guid.Empty) if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !"); throw new ArgumentException("messageID is empty.");
// 接收对方的消息 // 接收对方的消息
RemoteEditorConnection.Instance.HandlePlayerMessage(messageID, data); RemoteEditorConnection.Instance.HandlePlayerMessage(messageID, data);

View File

@@ -76,7 +76,7 @@ namespace YooAsset
else else
{ {
if (string.IsNullOrEmpty(_args.FileHash)) if (string.IsNullOrEmpty(_args.FileHash))
throw new YooInternalException("File hash is null or empty!"); throw new YooInternalException("File hash is null or empty.");
// 使用 Unity 缓存 // 使用 Unity 缓存
// 说明The file hash defining the version of the asset bundle. // 说明The file hash defining the version of the asset bundle.

View File

@@ -99,7 +99,7 @@ namespace YooAsset
if (_webRequest == null) if (_webRequest == null)
{ {
Status = EDownloadRequestStatus.Failed; Status = EDownloadRequestStatus.Failed;
Error = $"[{GetType().Name}] Created web request is null!"; Error = $"[{GetType().Name}] Created web request is null.";
} }
else else
{ {
@@ -226,7 +226,7 @@ namespace YooAsset
protected void ApplyRequestOptions(int timeout, int watchdogTime, Dictionary<string, string> headers) protected void ApplyRequestOptions(int timeout, int watchdogTime, Dictionary<string, string> headers)
{ {
if (_webRequest == null) if (_webRequest == null)
throw new YooInternalException("Web request is null!"); throw new YooInternalException("Web request is null.");
// 设置看门狗超时时间 // 设置看门狗超时时间
_watchdogTime = watchdogTime; _watchdogTime = watchdogTime;

View File

@@ -57,7 +57,7 @@ namespace YooAsset
#elif UNITY_STANDALONE_LINUX #elif UNITY_STANDALONE_LINUX
url = StringUtility.Format("file:///root/{0}", path); url = StringUtility.Format("file:///root/{0}", path);
#else #else
throw new System.NotSupportedException($"[{nameof(DownloadSystemHelper.ConvertToWWWPath)}] Platform '{UnityEngine.Application.platform}' is not supported!"); throw new System.NotSupportedException($"[{nameof(DownloadSystemHelper.ConvertToWWWPath)}] Platform '{UnityEngine.Application.platform}' is not supported.");
#endif #endif
// For some special cases when users have special characters in their devices, url paths can not be identified correctly. // For some special cases when users have special characters in their devices, url paths can not be identified correctly.

View File

@@ -39,7 +39,7 @@ namespace YooAsset
if (_assetBundle == null) if (_assetBundle == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !"; Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
return; return;
} }

View File

@@ -39,7 +39,7 @@ namespace YooAsset
if (_assetBundle == null) if (_assetBundle == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !"; Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
return; return;
} }

View File

@@ -72,7 +72,7 @@ namespace YooAsset
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
//注意:场景加载无法强制异步转同步 //注意:场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !"); YooLogger.Error("The scene is loading asyn.");
} }
else else
{ {

View File

@@ -39,7 +39,7 @@ namespace YooAsset
if (_assetBundle == null) if (_assetBundle == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !"; Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
return; return;
} }

View File

@@ -5,7 +5,7 @@ namespace YooAsset
{ {
internal override void InternalStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets !"; Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalUpdate() internal override void InternalUpdate()

View File

@@ -5,7 +5,7 @@ namespace YooAsset
{ {
internal override void InternalStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset !"; Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalUpdate() internal override void InternalUpdate()

View File

@@ -5,7 +5,7 @@ namespace YooAsset
{ {
internal override void InternalStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene !"; Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalUpdate() internal override void InternalUpdate()

View File

@@ -5,7 +5,7 @@ namespace YooAsset
{ {
internal override void InternalStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets !"; Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalUpdate() internal override void InternalUpdate()

View File

@@ -28,7 +28,7 @@ namespace YooAsset
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
#else #else
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadAllAssetsOperation)} only support unity editor platform !"; Error = $"{nameof(VirtualBundleLoadAllAssetsOperation)} only support unity editor platform.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }

View File

@@ -27,7 +27,7 @@ namespace YooAsset
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
#else #else
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadAssetOperation)} only support unity editor platform !"; Error = $"{nameof(VirtualBundleLoadAssetOperation)} only support unity editor platform.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }

View File

@@ -31,7 +31,7 @@ namespace YooAsset
_steps = ESteps.LoadScene; _steps = ESteps.LoadScene;
#else #else
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadSceneOperation)} only support unity editor platform !"; Error = $"{nameof(VirtualBundleLoadSceneOperation)} only support unity editor platform.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }
@@ -77,7 +77,7 @@ namespace YooAsset
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
// 注意:场景加载无法强制异步转同步 // 注意:场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !"); YooLogger.Error("The scene is loading asyn.");
} }
else else
{ {

View File

@@ -28,7 +28,7 @@ namespace YooAsset
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
#else #else
_steps = ESteps.Done; _steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadSubAssetsOperation)} only support unity editor platform !"; Error = $"{nameof(VirtualBundleLoadSubAssetsOperation)} only support unity editor platform.";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }

View File

@@ -206,7 +206,7 @@ namespace YooAsset
public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData) public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData)
{ {
if (binaryData == null || binaryData.Length == 0) if (binaryData == null || binaryData.Length == 0)
throw new Exception("Catalog file data is null or empty !"); throw new Exception("Catalog file data is null or empty.");
// 创建缓存器 // 创建缓存器
BufferReader buffer = new BufferReader(binaryData); BufferReader buffer = new BufferReader(binaryData);
@@ -214,7 +214,7 @@ namespace YooAsset
// 读取文件标记 // 读取文件标记
uint fileSign = buffer.ReadUInt32(); uint fileSign = buffer.ReadUInt32();
if (fileSign != CatalogFileDefine.FileSign) if (fileSign != CatalogFileDefine.FileSign)
throw new Exception("Invalid catalog file !"); throw new Exception("Invalid catalog file.");
// 读取文件版本 // 读取文件版本
string fileVersion = buffer.ReadUTF8(); string fileVersion = buffer.ReadUTF8();

View File

@@ -333,14 +333,14 @@ namespace YooAsset
#if UNITY_ANDROID #if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。 //TODO : 安卓平台内置文件属于APK压缩包内的文件。
YooLogger.Error($"Android platform not support read buildin bundle file data !"); YooLogger.Error($"Android platform not support read buildin bundle file data.");
return null; return null;
#else #else
if (bundle.Encrypted) if (bundle.Encrypted)
{ {
if (DecryptionServices == null) if (DecryptionServices == null)
{ {
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !"); YooLogger.Error($"The {nameof(IDecryptionServices)} is null.");
return null; return null;
} }
@@ -370,14 +370,14 @@ namespace YooAsset
#if UNITY_ANDROID #if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。 //TODO : 安卓平台内置文件属于APK压缩包内的文件。
YooLogger.Error($"Android platform not support read buildin bundle file text !"); YooLogger.Error($"Android platform not support read buildin bundle file text.");
return null; return null;
#else #else
if (bundle.Encrypted) if (bundle.Encrypted)
{ {
if (DecryptionServices == null) if (DecryptionServices == null)
{ {
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !"); YooLogger.Error($"The {nameof(IDecryptionServices)} is null.");
return null; return null;
} }

View File

@@ -33,7 +33,7 @@ namespace YooAsset
#if UNITY_WEBGL #if UNITY_WEBGL
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !"; Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform.";
#else #else
if (_fileSystem.CopyBuildinPackageManifest) if (_fileSystem.CopyBuildinPackageManifest)
_steps = ESteps.LoadBuildinPackageVersion; _steps = ESteps.LoadBuildinPackageVersion;
@@ -181,7 +181,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Fatal error : catalog is null !"; Error = "Fatal error : catalog is null.";
return; return;
} }

View File

@@ -48,7 +48,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The {nameof(IBundleDecryptionServices)} is null !"; Error = $"The {nameof(IBundleDecryptionServices)} is null.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }
@@ -247,7 +247,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The {nameof(IDecryptionServices)} is null !"; Error = $"The {nameof(IDecryptionServices)} is null.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }

View File

@@ -94,7 +94,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to verify buildin package manifest file !"; Error = "Failed to verify buildin package manifest file.";
} }
} }

View File

@@ -85,7 +85,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Buildin package hash file content is empty !"; Error = $"Buildin package hash file content is empty.";
} }
else else
{ {

View File

@@ -83,7 +83,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Buildin package version file content is empty !"; Error = $"Buildin package version file content is empty.";
} }
else else
{ {

View File

@@ -407,7 +407,7 @@ namespace YooAsset
{ {
if (BundleDecryptionServices == null) if (BundleDecryptionServices == null)
{ {
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !"); YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null.");
return null; return null;
} }
@@ -435,7 +435,7 @@ namespace YooAsset
{ {
if (BundleDecryptionServices == null) if (BundleDecryptionServices == null)
{ {
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !"); YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null.");
return null; return null;
} }
@@ -552,7 +552,7 @@ namespace YooAsset
} }
catch (Exception ex) catch (Exception ex)
{ {
YooLogger.Error($"Failed to write cache file ! {ex.Message}"); YooLogger.Error($"Failed to write cache file. Error: {ex.Message}");
return false; return false;
} }

View File

@@ -39,7 +39,7 @@ namespace YooAsset
} }
catch (Exception ex) catch (Exception ex)
{ {
YooLogger.Error($"Failed to delete cache file ! {ex.Message}"); YooLogger.Error($"Failed to delete cache file. Error: {ex.Message}");
return false; return false;
} }
} }

View File

@@ -28,7 +28,7 @@ namespace YooAsset
#if UNITY_WEBGL #if UNITY_WEBGL
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DefaultCacheFileSystem)} is not support WEBGL platform !"; Error = $"{nameof(DefaultCacheFileSystem)} is not support WEBGL platform.";
#else #else
_steps = ESteps.CheckAppFootPrint; _steps = ESteps.CheckAppFootPrint;
#endif #endif
@@ -48,23 +48,23 @@ namespace YooAsset
{ {
if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.None) if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.None)
{ {
YooLogger.Warning("Do nothing when overwrite install application !"); YooLogger.Warning("Do nothing when overwrite install application.");
} }
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllCacheFiles) else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllCacheFiles)
{ {
_fileSystem.DeleteAllBundleFiles(); _fileSystem.DeleteAllBundleFiles();
_fileSystem.DeleteAllManifestFiles(); _fileSystem.DeleteAllManifestFiles();
YooLogger.Warning("Delete all cache files when overwrite install application !"); YooLogger.Warning("Delete all cache files when overwrite install application.");
} }
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllBundleFiles) else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllBundleFiles)
{ {
_fileSystem.DeleteAllBundleFiles(); _fileSystem.DeleteAllBundleFiles();
YooLogger.Warning("Delete all bundle files when overwrite install application !"); YooLogger.Warning("Delete all bundle files when overwrite install application.");
} }
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllManifestFiles) else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllManifestFiles)
{ {
_fileSystem.DeleteAllManifestFiles(); _fileSystem.DeleteAllManifestFiles();
YooLogger.Warning("Delete all manifest files when overwrite install application !"); YooLogger.Warning("Delete all manifest files when overwrite install application.");
} }
else else
{ {

View File

@@ -120,7 +120,7 @@ namespace YooAsset
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Abort download file !"; Error = "Abort download file.";
} }
if (_steps == ESteps.LoadAssetBundle) if (_steps == ESteps.LoadAssetBundle)
@@ -131,7 +131,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The {nameof(IBundleDecryptionServices)} is null !"; Error = $"The {nameof(IBundleDecryptionServices)} is null.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }
@@ -389,7 +389,7 @@ namespace YooAsset
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Abort download file !"; Error = "Abort download file.";
} }
if (_steps == ESteps.LoadCacheRawBundle) if (_steps == ESteps.LoadCacheRawBundle)

View File

@@ -45,7 +45,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Can not found active package manifest !"; Error = "Can not found active package manifest.";
} }
else else
{ {
@@ -59,7 +59,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Clear param is null !"; Error = "Clear param is null.";
return; return;
} }

View File

@@ -43,7 +43,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Can not found active package manifest !"; Error = "Can not found active package manifest.";
} }
else else
{ {
@@ -57,7 +57,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Clear param is null !"; Error = "Clear param is null.";
return; return;
} }

View File

@@ -41,7 +41,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Can not found active package manifest !"; Error = "Can not found active package manifest.";
} }
else else
{ {

View File

@@ -38,7 +38,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Can not found active package manifest !"; Error = "Can not found active package manifest.";
} }
else else
{ {

View File

@@ -62,7 +62,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Download file options is invalid !"; Error = "Download file options is invalid.";
Debug.Log(Error); Debug.Log(Error);
return; return;
} }
@@ -95,7 +95,7 @@ namespace YooAsset
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0) if (IsWaitForAsyncComplete == false && _failedTryAgain > 0)
{ {
_steps = ESteps.TryAgain; _steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_downloadFileOp.URL} Try again !"); YooLogger.Warning($"Failed download : {_downloadFileOp.URL} Try again.");
} }
else else
{ {

View File

@@ -51,7 +51,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Cache package hash file content is empty !"; Error = $"Cache package hash file content is empty.";
} }
else else
{ {

View File

@@ -67,7 +67,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to verify cache package manifest file!"; Error = "Failed to verify cache package manifest file.";
} }
} }

View File

@@ -62,7 +62,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Remote package version file content is empty !"; Error = $"Remote package version file content is empty.";
} }
else else
{ {

View File

@@ -170,7 +170,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{_fileSystem.GetType().FullName} failed to write file !"; Error = $"{_fileSystem.GetType().FullName} failed to write file.";
} }
// 注意:缓存完成后直接删除临时文件 // 注意:缓存完成后直接删除临时文件

View File

@@ -133,7 +133,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{_fileSystem.GetType().FullName} failed to write file !"; Error = $"{_fileSystem.GetType().FullName} failed to write file.";
} }
// 注意:缓存完成后直接删除临时文件 // 注意:缓存完成后直接删除临时文件
@@ -151,7 +151,7 @@ namespace YooAsset
if (_steps != ESteps.Done) if (_steps != ESteps.Done)
{ {
// 注意:不中断下载任务,保持后台继续下载 // 注意:不中断下载任务,保持后台继续下载
YooLogger.Error($"Try load bundle {_bundle.BundleName} from remote : {URL} !"); YooLogger.Error($"Try load bundle {_bundle.BundleName} from remote : {URL}");
} }
} }

View File

@@ -63,7 +63,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Failed to verify file : {_element.TempFilePath} ! ErrorCode : {VerifyResult}"; Error = $"Failed to verify file : {_element.TempFilePath} ErrorCode : {VerifyResult}";
} }
} }
} }

View File

@@ -161,7 +161,7 @@ namespace YooAsset
PackageName = packageName; PackageName = packageName;
if (string.IsNullOrEmpty(packageRoot)) if (string.IsNullOrEmpty(packageRoot))
throw new YooFileSystemException($"{nameof(DefaultEditorFileSystem)} package root is null or empty !"); throw new YooFileSystemException($"{nameof(DefaultEditorFileSystem)} package root is null or empty.");
_packageRoot = packageRoot; _packageRoot = packageRoot;

View File

@@ -105,7 +105,7 @@ namespace YooAsset
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Abort download file !"; Error = "Abort download file.";
} }
if (_steps == ESteps.LoadAssetBundle) if (_steps == ESteps.LoadAssetBundle)
@@ -116,7 +116,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Virtual WebGL Mode only support asyn load method !"; Error = "Virtual WebGL Mode only support asyn load method.";
YooLogger.Error(Error); YooLogger.Error(Error);
} }
else else

View File

@@ -61,7 +61,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Download file options is invalid !"; Error = "Download file options is invalid.";
Debug.Log(Error); Debug.Log(Error);
return; return;
} }
@@ -94,7 +94,7 @@ namespace YooAsset
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0) if (IsWaitForAsyncComplete == false && _failedTryAgain > 0)
{ {
_steps = ESteps.TryAgain; _steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_downloadFileOp.URL} Try again !"); YooLogger.Warning($"Failed download : {_downloadFileOp.URL} Try again.");
} }
else else
{ {
@@ -127,7 +127,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Try load bundle {Bundle.BundleName} from remote !"; Error = $"Try load bundle {Bundle.BundleName} from remote.";
YooLogger.Error(Error); YooLogger.Error(Error);
} }
} }

View File

@@ -67,7 +67,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to verify simulation package manifest file !"; Error = "Failed to verify simulation package manifest file.";
} }
} }

View File

@@ -67,7 +67,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DWRFSLoadAssetBundleOperation)} loaded asset bundle is null !"; Error = $"{nameof(DWRFSLoadAssetBundleOperation)} loaded asset bundle is null.";
} }
else else
{ {
@@ -90,7 +90,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "WebGL platform not support sync load method !"; Error = "WebGL platform not support sync load method.";
YooLogger.Error(Error); YooLogger.Error(Error);
} }
} }

View File

@@ -67,7 +67,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DWSFSLoadAssetBundleOperation)} loaded asset bundle is null !"; Error = $"{nameof(DWSFSLoadAssetBundleOperation)} loaded asset bundle is null.";
} }
else else
{ {
@@ -90,7 +90,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "WebGL platform not support sync load method !"; Error = "WebGL platform not support sync load method.";
YooLogger.Error(Error); YooLogger.Error(Error);
} }
} }

View File

@@ -78,7 +78,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to verify web server package manifest file!"; Error = "Failed to verify web server package manifest file.";
} }
} }

View File

@@ -59,7 +59,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Web server package hash file content is empty !"; Error = $"Web server package hash file content is empty.";
} }
else else
{ {

View File

@@ -56,7 +56,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Web server package version file content is empty !"; Error = $"Web server package version file content is empty.";
} }
else else
{ {

View File

@@ -46,7 +46,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The {nameof(IWebBundleDecryptionServices)} is null !"; Error = $"The {nameof(IWebBundleDecryptionServices)} is null.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }
@@ -75,7 +75,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed load encrypted AssetBundle !"; Error = "Failed load encrypted AssetBundle.";
} }
else else
{ {
@@ -89,7 +89,7 @@ namespace YooAsset
if (_failedTryAgain > 0) if (_failedTryAgain > 0)
{ {
_steps = ESteps.TryAgain; _steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_unityWebDataRequestOp.URL} Try again !"); YooLogger.Warning($"Failed download : {_unityWebDataRequestOp.URL} Try again.");
} }
else else
{ {

View File

@@ -70,7 +70,7 @@ namespace YooAsset
if (_failedTryAgain > 0) if (_failedTryAgain > 0)
{ {
_steps = ESteps.TryAgain; _steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_unityAssetBundleRequestOp.URL} Try again !"); YooLogger.Warning($"Failed download : {_unityAssetBundleRequestOp.URL} Try again.");
} }
else else
{ {

View File

@@ -88,7 +88,7 @@ internal class LoadWebPackageManifestOperation : AsyncOperationBase
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to verify web package manifest file!"; Error = "Failed to verify web package manifest file.";
} }
} }

View File

@@ -64,7 +64,7 @@ internal class RequestWebPackageHashOperation : AsyncOperationBase
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Web package hash file content is empty !"; Error = $"Web package hash file content is empty.";
} }
else else
{ {

View File

@@ -64,7 +64,7 @@ internal class RequestWebPackageVersionOperation : AsyncOperationBase
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Web package version file content is empty !"; Error = $"Web package version file content is empty.";
} }
else else
{ {

View File

@@ -158,13 +158,13 @@ namespace YooAsset
#if UNITY_EDITOR || DEBUG #if UNITY_EDITOR || DEBUG
if (child == null) if (child == null)
throw new YooInternalException("The child node is null !"); throw new YooInternalException("The child node is null.");
if (ReferenceEquals(child, this)) if (ReferenceEquals(child, this))
throw new YooInternalException("The child node cannot be itself !"); throw new YooInternalException("The child node cannot be itself.");
if (_childs.Contains(child)) if (_childs.Contains(child))
throw new YooInternalException($"The child node {child.GetType().Name} already exists !"); throw new YooInternalException($"The child node {child.GetType().Name} already exists.");
// 禁止形成环依赖 // 禁止形成环依赖
if (WouldCreateCycle(child)) if (WouldCreateCycle(child))
@@ -184,10 +184,10 @@ namespace YooAsset
#if UNITY_EDITOR || DEBUG #if UNITY_EDITOR || DEBUG
if (child == null) if (child == null)
throw new YooInternalException("The child node is null !"); throw new YooInternalException("The child node is null.");
if (_childs.Contains(child) == false) if (_childs.Contains(child) == false)
throw new YooInternalException($"The child node {child.GetType().Name} not exists !"); throw new YooInternalException($"The child node {child.GetType().Name} not exists.");
#endif #endif
_childs.Remove(child); _childs.Remove(child);
@@ -276,7 +276,7 @@ namespace YooAsset
InternalAbort(); InternalAbort();
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "user abort"; Error = "user abort";
YooLogger.Warning($"Async operation {this.GetType().Name} has been aborted !"); YooLogger.Warning($"Async operation {this.GetType().Name} has been aborted.");
} }
//注意强制收尾确保Task能完成 //注意强制收尾确保Task能完成
@@ -398,7 +398,7 @@ namespace YooAsset
if (IsDone == false) if (IsDone == false)
{ {
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Operation {this.GetType().Name} failed to wait for async complete !"; Error = $"Operation {this.GetType().Name} failed to wait for async complete.";
YooLogger.Error(Error); YooLogger.Error(Error);
} }
@@ -481,7 +481,7 @@ namespace YooAsset
// 防止无限循环(图过大) // 防止无限循环(图过大)
if (visited.Count > MaxCycleCheckDepth) if (visited.Count > MaxCycleCheckDepth)
throw new YooInternalException("Child operation graph is too large, cycle check aborted !"); throw new YooInternalException("Child operation graph is too large, cycle check aborted.");
// 检测循环:如果遍历到自己,说明形成循环 // 检测循环:如果遍历到自己,说明形成循环
if (ReferenceEquals(node, this)) if (ReferenceEquals(node, this))

View File

@@ -77,7 +77,7 @@ namespace YooAsset
{ {
if (_isInitialized) if (_isInitialized)
{ {
YooLogger.Warning("Operation system is already initialized!"); YooLogger.Warning("Operation system is already initialized.");
return; return;
} }
@@ -174,7 +174,7 @@ namespace YooAsset
// 不允许销毁默认调度器 // 不允许销毁默认调度器
if (packageName == GlobalSchedulerName) if (packageName == GlobalSchedulerName)
{ {
throw new YooInternalException("Cannot destroy the global package scheduler!"); throw new YooInternalException("Cannot destroy the global package scheduler.");
} }
if (_schedulerDic.TryGetValue(packageName, out var scheduler)) if (_schedulerDic.TryGetValue(packageName, out var scheduler))
@@ -261,7 +261,7 @@ namespace YooAsset
throw new YooInternalException("Package name is null or empty."); throw new YooInternalException("Package name is null or empty.");
if (_isInitialized == false) if (_isInitialized == false)
throw new YooInternalException($"{nameof(OperationSystem)} not initialized !"); throw new YooInternalException($"{nameof(OperationSystem)} not initialized.");
} }
#endregion #endregion
} }

View File

@@ -116,14 +116,14 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Instantiate game object is null !"; Error = $"Instantiate game object is null.";
} }
} }
else else
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Instantiate async results is null !"; Error = $"Instantiate async results is null.";
} }
} }
#endif #endif

View File

@@ -84,7 +84,7 @@ namespace YooAsset
if (_loadBundleOp == null) if (_loadBundleOp == null)
{ {
// 统计计数增加 // 统计计数增加
_resManager.BundleLoadingCounter++; _resManager.IncrementBundleLoadingCounter();
_loadBundleOp = LoadBundleInfo.CreateBundleLoader(); _loadBundleOp = LoadBundleInfo.CreateBundleLoader();
_loadBundleOp.StartOperation(); _loadBundleOp.StartOperation();
AddChildOperation(_loadBundleOp); AddChildOperation(_loadBundleOp);
@@ -105,7 +105,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The bundle loader result is null ! {LoadBundleInfo.Bundle.BundleName}"; Error = $"The bundle loader result is null. Bundle: {LoadBundleInfo.Bundle.BundleName}";
} }
else else
{ {
@@ -122,7 +122,7 @@ namespace YooAsset
} }
// 统计计数减少 // 统计计数减少
_resManager.BundleLoadingCounter--; _resManager.DecrementBundleLoadingCounter();
} }
} }
internal override void InternalWaitForAsyncComplete() internal override void InternalWaitForAsyncComplete()
@@ -171,7 +171,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Bundle loader destroyed !"; Error = "Bundle loader destroyed.";
} }
} }
@@ -268,7 +268,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Abort bundle loader !"; Error = "Bundle loader aborted.";
} }
if (_steps == ESteps.LoadBundleFile) if (_steps == ESteps.LoadBundleFile)

View File

@@ -73,7 +73,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Scene is invalid !"; Error = "Scene is invalid.";
return; return;
} }
@@ -81,7 +81,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Scene is not loaded !"; Error = "Scene is not loaded.";
return; return;
} }
@@ -97,7 +97,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Unload scene failed, see the console logs !"; Error = "Unload scene failed, see the console logs.";
return; return;
} }
} }

View File

@@ -168,7 +168,7 @@ namespace YooAsset
BundleResultObject = _mainBundleLoader.Result; BundleResultObject = _mainBundleLoader.Result;
if (BundleResultObject == null) if (BundleResultObject == null)
{ {
string error = $"Loaded bundle result is null !"; string error = $"Loaded bundle result is null.";
InvokeCompletion(error, EOperationStatus.Failed); InvokeCompletion(error, EOperationStatus.Failed);
return; return;
} }

View File

@@ -7,18 +7,24 @@ using UnityEngine.SceneManagement;
namespace YooAsset namespace YooAsset
{ {
/// <summary>
/// 资源管理器
/// 注意此类不是线程安全的所有方法必须在Unity主线程调用
/// </summary>
internal class ResourceManager internal class ResourceManager
{ {
internal readonly Dictionary<string, ProviderOperation> ProviderDic = new Dictionary<string, ProviderOperation>(5000); internal readonly Dictionary<string, ProviderOperation> ProviderDic = new Dictionary<string, ProviderOperation>(5000);
internal readonly Dictionary<string, LoadBundleOperation> LoaderDic = new Dictionary<string, LoadBundleOperation>(5000); internal readonly Dictionary<string, LoadBundleOperation> LoaderDic = new Dictionary<string, LoadBundleOperation>(5000);
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100); internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
private readonly List<SceneHandle> _tempSceneHandles = new List<SceneHandle>(100);
private FileSystemHost _fileSystemHost; private FileSystemHost _fileSystemHost;
private long _sceneCreateIndex = 0;
private int _bundleLoadingMaxConcurrency; private int _bundleLoadingMaxConcurrency;
private int _bundleLoadingCounter;
private long _sceneCreateIndex;
// 开发者配置选项 // 开发者配置选项
public bool AutoUnloadBundleWhenUnused { private set; get; } public bool AutoUnloadBundleWhenUnused { get; private set; }
public bool WebGLForceSyncLoadAsset { private set; get; } public bool WebGLForceSyncLoadAsset { get; private set; }
/// <summary> /// <summary>
/// 所属包裹 /// 所属包裹
@@ -30,12 +36,6 @@ namespace YooAsset
/// </summary> /// </summary>
public bool LockLoadOperation = false; public bool LockLoadOperation = false;
/// <summary>
/// 统计正在加载的Bundle文件数量
/// </summary>
public int BundleLoadingCounter = 0;
public ResourceManager(string packageName) public ResourceManager(string packageName)
{ {
PackageName = packageName; PackageName = packageName;
@@ -68,18 +68,21 @@ namespace YooAsset
{ {
if (assetInfo == null) if (assetInfo == null)
{ {
YooLogger.Error($"{nameof(AssetInfo)} is null !"); YooLogger.Error($"{nameof(AssetInfo)} is null.");
return; return;
} }
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to unload asset ! {assetInfo.Error}"); YooLogger.Error($"Failed to unload asset. Error: {assetInfo.Error}");
return; return;
} }
// 多次循环尝试卸载,以处理复杂的依赖链
// 例如A依赖BB依赖C需要多次循环才能完全卸载
while (loopCount > 0) while (loopCount > 0)
{ {
loopCount--; loopCount--;
bool hasUnloaded = false;
// 卸载主资源包加载器 // 卸载主资源包加载器
string mainBundleName = _fileSystemHost.GetMainBundleName(assetInfo.Asset.BundleID); string mainBundleName = _fileSystemHost.GetMainBundleName(assetInfo.Asset.BundleID);
@@ -91,6 +94,7 @@ namespace YooAsset
{ {
mainLoader.DestroyLoader(); mainLoader.DestroyLoader();
LoaderDic.Remove(mainBundleName); LoaderDic.Remove(mainBundleName);
hasUnloaded = true;
} }
} }
@@ -105,9 +109,14 @@ namespace YooAsset
{ {
dependLoader.DestroyLoader(); dependLoader.DestroyLoader();
LoaderDic.Remove(dependBundleName); LoaderDic.Remove(dependBundleName);
hasUnloaded = true;
} }
} }
} }
// 如果本次循环没有卸载任何资源,提前退出
if (hasUnloaded == false)
break;
} }
} }
@@ -120,7 +129,7 @@ namespace YooAsset
{ {
if (LockLoadOperation) if (LockLoadOperation)
{ {
string error = $"The load operation locked !"; string error = $"The load operation locked.";
YooLogger.Error(error); YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(error); completedProvider.SetCompletedWithError(error);
@@ -129,7 +138,7 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to load scene ! {assetInfo.Error}"); YooLogger.Error($"Failed to load scene. Error: {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(assetInfo.Error); completedProvider.SetCompletedWithError(assetInfo.Error);
return completedProvider.CreateHandle<SceneHandle>(); return completedProvider.CreateHandle<SceneHandle>();
@@ -159,7 +168,7 @@ namespace YooAsset
{ {
if (LockLoadOperation) if (LockLoadOperation)
{ {
string error = $"The load operation locked !"; string error = $"The load operation locked.";
YooLogger.Error(error); YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(error); completedProvider.SetCompletedWithError(error);
@@ -168,7 +177,7 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to load asset ! {assetInfo.Error}"); YooLogger.Error($"Failed to load asset. Error: {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(assetInfo.Error); completedProvider.SetCompletedWithError(assetInfo.Error);
return completedProvider.CreateHandle<AssetHandle>(); return completedProvider.CreateHandle<AssetHandle>();
@@ -195,7 +204,7 @@ namespace YooAsset
{ {
if (LockLoadOperation) if (LockLoadOperation)
{ {
string error = $"The load operation locked !"; string error = $"The load operation locked.";
YooLogger.Error(error); YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(error); completedProvider.SetCompletedWithError(error);
@@ -204,7 +213,7 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to load sub assets ! {assetInfo.Error}"); YooLogger.Error($"Failed to load sub assets. Error: {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(assetInfo.Error); completedProvider.SetCompletedWithError(assetInfo.Error);
return completedProvider.CreateHandle<SubAssetsHandle>(); return completedProvider.CreateHandle<SubAssetsHandle>();
@@ -231,7 +240,7 @@ namespace YooAsset
{ {
if (LockLoadOperation) if (LockLoadOperation)
{ {
string error = $"The load operation locked !"; string error = $"The load operation locked.";
YooLogger.Error(error); YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(error); completedProvider.SetCompletedWithError(error);
@@ -240,7 +249,7 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to load all assets ! {assetInfo.Error}"); YooLogger.Error($"Failed to load all assets. Error: {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(assetInfo.Error); completedProvider.SetCompletedWithError(assetInfo.Error);
return completedProvider.CreateHandle<AllAssetsHandle>(); return completedProvider.CreateHandle<AllAssetsHandle>();
@@ -267,7 +276,7 @@ namespace YooAsset
{ {
if (LockLoadOperation) if (LockLoadOperation)
{ {
string error = $"The load operation locked !"; string error = $"The load operation locked.";
YooLogger.Error(error); YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(error); completedProvider.SetCompletedWithError(error);
@@ -276,7 +285,7 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to load raw file ! {assetInfo.Error}"); YooLogger.Error($"Failed to load raw file. Error: {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(this, assetInfo); CompletedProvider completedProvider = new CompletedProvider(this, assetInfo);
completedProvider.SetCompletedWithError(assetInfo.Error); completedProvider.SetCompletedWithError(assetInfo.Error);
return completedProvider.CreateHandle<RawFileHandle>(); return completedProvider.CreateHandle<RawFileHandle>();
@@ -339,9 +348,26 @@ namespace YooAsset
{ {
return LoaderDic.Count > 0; return LoaderDic.Count > 0;
} }
internal void IncrementBundleLoadingCounter()
{
_bundleLoadingCounter++;
}
internal void DecrementBundleLoadingCounter()
{
_bundleLoadingCounter--;
if (_bundleLoadingCounter < 0)
{
YooLogger.Error("BundleLoadingCounter is negative.");
_bundleLoadingCounter = 0;
}
}
internal int GetBundleLoadingCounter()
{
return _bundleLoadingCounter;
}
internal bool BundleLoadingIsBusy() internal bool BundleLoadingIsBusy()
{ {
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency; return _bundleLoadingCounter >= _bundleLoadingMaxConcurrency;
} }
private LoadBundleOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo) private LoadBundleOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
@@ -373,7 +399,7 @@ namespace YooAsset
} }
private void OnSceneUnloaded(Scene scene) private void OnSceneUnloaded(Scene scene)
{ {
List<SceneHandle> removeList = new List<SceneHandle>(); _tempSceneHandles.Clear(); //复用列表
foreach (var sceneHandle in SceneHandles) foreach (var sceneHandle in SceneHandles)
{ {
if (sceneHandle.IsValid) if (sceneHandle.IsValid)
@@ -381,11 +407,11 @@ namespace YooAsset
if (sceneHandle.SceneObject == scene) if (sceneHandle.SceneObject == scene)
{ {
sceneHandle.Release(); sceneHandle.Release();
removeList.Add(sceneHandle); _tempSceneHandles.Add(sceneHandle);
} }
} }
} }
foreach (var sceneHandle in removeList) foreach (var sceneHandle in _tempSceneHandles)
{ {
SceneHandles.Remove(sceneHandle); SceneHandles.Remove(sceneHandle);
} }

View File

@@ -114,7 +114,7 @@ namespace YooAsset
var fileSystem = GetBelongFileSystem(packageBundle); var fileSystem = GetBelongFileSystem(packageBundle);
if (fileSystem != null) if (fileSystem != null)
{ {
BundleInfo bundleInfo = new BundleInfo(fileSystem, packageBundle); var bundleInfo = new BundleInfo(fileSystem, packageBundle);
return bundleInfo; return bundleInfo;
} }
@@ -209,9 +209,9 @@ namespace YooAsset
{ {
List<BundleInfo> downloadList; List<BundleInfo> downloadList;
if (options.Tags == null) if (options.Tags == null)
downloadList = GetBundleListByAll(manifest, NeedDownload); downloadList = GetBundleInfoListByAll(manifest, NeedDownload);
else else
downloadList = GetBundleListByTags(manifest, options.Tags, NeedDownload); downloadList = GetBundleInfoListByTags(manifest, options.Tags, NeedDownload);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain); var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain);
return operation; return operation;
@@ -225,9 +225,9 @@ namespace YooAsset
{ {
List<BundleInfo> downloadList; List<BundleInfo> downloadList;
if (options.AssetInfos == null) if (options.AssetInfos == null)
downloadList = GetBundleListByAll(manifest, NeedDownload); downloadList = GetBundleInfoListByAll(manifest, NeedDownload);
else else
downloadList = GetBundleListByAssetInfos(manifest, options.AssetInfos, options.DownloadBundleDependencies, NeedDownload); downloadList = GetBundleInfoListByAssetInfos(manifest, options.AssetInfos, options.DownloadBundleDependencies, NeedDownload);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain); var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain);
return operation; return operation;
@@ -241,9 +241,9 @@ namespace YooAsset
{ {
List<BundleInfo> unpackList; List<BundleInfo> unpackList;
if (options.Tags == null) if (options.Tags == null)
unpackList = GetBundleListByAll(manifest, NeedUnpack); unpackList = GetBundleInfoListByAll(manifest, NeedUnpack);
else else
unpackList = GetBundleListByTags(manifest, options.Tags, NeedUnpack); unpackList = GetBundleInfoListByTags(manifest, options.Tags, NeedUnpack);
var operation = new ResourceUnpackerOperation(PackageName, unpackList, options.MaximumConcurrency, options.FailedTryAgain); var operation = new ResourceUnpackerOperation(PackageName, unpackList, options.MaximumConcurrency, options.FailedTryAgain);
return operation; return operation;
@@ -255,12 +255,12 @@ namespace YooAsset
} }
public ResourceImporterOperation CreateResourceImporter(PackageManifest manifest, BundleImporterOptions options) public ResourceImporterOperation CreateResourceImporter(PackageManifest manifest, BundleImporterOptions options)
{ {
List<BundleInfo> importerList = GetBundleListByBundleInfos(manifest, options.BundleInfos, NeedImport); List<BundleInfo> importerList = GetBundleInfoListByBundleInfos(manifest, options.BundleInfos, NeedImport);
var operation = new ResourceImporterOperation(PackageName, importerList, options.MaximumConcurrency, options.FailedTryAgain); var operation = new ResourceImporterOperation(PackageName, importerList, options.MaximumConcurrency, options.FailedTryAgain);
return operation; return operation;
} }
private List<BundleInfo> GetBundleListByAll(PackageManifest manifest, Func<IFileSystem, PackageBundle, bool> predicate) private List<BundleInfo> GetBundleInfoListByAll(PackageManifest manifest, Func<IFileSystem, PackageBundle, bool> predicate)
{ {
if (manifest == null) if (manifest == null)
return new List<BundleInfo>(); return new List<BundleInfo>();
@@ -280,7 +280,7 @@ namespace YooAsset
} }
return result; return result;
} }
private List<BundleInfo> GetBundleListByTags(PackageManifest manifest, string[] tags, Func<IFileSystem, PackageBundle, bool> predicate) private List<BundleInfo> GetBundleInfoListByTags(PackageManifest manifest, string[] tags, Func<IFileSystem, PackageBundle, bool> predicate)
{ {
if (manifest == null) if (manifest == null)
return new List<BundleInfo>(); return new List<BundleInfo>();
@@ -312,7 +312,7 @@ namespace YooAsset
} }
return result; return result;
} }
private List<BundleInfo> GetBundleListByAssetInfos(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDepend, Func<IFileSystem, PackageBundle, bool> predicate) private List<BundleInfo> GetBundleInfoListByAssetInfos(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDepend, Func<IFileSystem, PackageBundle, bool> predicate)
{ {
if (manifest == null) if (manifest == null)
return new List<BundleInfo>(); return new List<BundleInfo>();
@@ -387,7 +387,7 @@ namespace YooAsset
} }
return result; return result;
} }
private List<BundleInfo> GetBundleListByBundleInfos(PackageManifest manifest, ImportBundleInfo[] fileInfos, Func<IFileSystem, PackageBundle, bool> predicate) private List<BundleInfo> GetBundleInfoListByBundleInfos(PackageManifest manifest, ImportBundleInfo[] fileInfos, Func<IFileSystem, PackageBundle, bool> predicate)
{ {
if (manifest == null) if (manifest == null)
return new List<BundleInfo>(); return new List<BundleInfo>();

View File

@@ -36,27 +36,27 @@ namespace YooAsset
if (_steps == ESteps.Prepare) if (_steps == ESteps.Prepare)
{ {
var fileSytems = _host.FileSystems; var fileSystems = _host.FileSystems;
if (fileSytems == null || fileSytems.Count == 0) if (fileSystems == null || fileSystems.Count == 0)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "The file system is empty !"; Error = "The file system is empty.";
return; return;
} }
foreach (var fileSystem in fileSytems) foreach (var fileSystem in fileSystems)
{ {
if (fileSystem == null) if (fileSystem == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "An empty object exists in the list!"; Error = "An empty object exists in the list.";
return; return;
} }
} }
_cloneList = fileSytems.ToList(); _cloneList = fileSystems.ToList();
_steps = ESteps.ClearCacheFiles; _steps = ESteps.ClearCacheFiles;
} }

View File

@@ -43,7 +43,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "The Package is initializing ! Please try to destroy the package again later."; Error = "The Package is initializing. Please try to destroy the package again later.";
} }
else if (_resourcePackage.InitializeStatus == EOperationStatus.Failed) else if (_resourcePackage.InitializeStatus == EOperationStatus.Failed)
{ {

View File

@@ -87,7 +87,7 @@ namespace YooAsset
_failedTryAgain = failedTryAgain; _failedTryAgain = failedTryAgain;
// 统计下载信息 // 统计下载信息
CalculatDownloaderInfo(); CalculateDownloaderInfo();
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -262,7 +262,7 @@ namespace YooAsset
} }
} }
} }
private void CalculatDownloaderInfo() private void CalculateDownloaderInfo()
{ {
if (_bundleInfoList != null) if (_bundleInfoList != null)
{ {
@@ -288,23 +288,23 @@ namespace YooAsset
{ {
if (_packageName != downloader._packageName) if (_packageName != downloader._packageName)
{ {
YooLogger.Error("The downloaders have different resource packages !"); YooLogger.Error("The downloaders have different resource packages.");
return; return;
} }
if (Status != EOperationStatus.None) if (Status != EOperationStatus.None)
{ {
YooLogger.Error("The downloader is running, can not combine with other downloader !"); YooLogger.Error("The downloader is running, can not combine with other downloader.");
return; return;
} }
HashSet<string> temper = new HashSet<string>(); HashSet<string> combineGuidSet = new HashSet<string>();
foreach (var bundleInfo in _bundleInfoList) foreach (var bundleInfo in _bundleInfoList)
{ {
string combineGUID = bundleInfo.GetDownloadCombineGUID(); string combineGUID = bundleInfo.GetDownloadCombineGUID();
if (temper.Contains(combineGUID) == false) if (combineGuidSet.Contains(combineGUID) == false)
{ {
temper.Add(combineGUID); combineGuidSet.Add(combineGUID);
} }
} }
@@ -312,14 +312,14 @@ namespace YooAsset
foreach (var bundleInfo in downloader._bundleInfoList) foreach (var bundleInfo in downloader._bundleInfoList)
{ {
string combineGUID = bundleInfo.GetDownloadCombineGUID(); string combineGUID = bundleInfo.GetDownloadCombineGUID();
if (temper.Contains(combineGUID) == false) if (combineGuidSet.Contains(combineGUID) == false)
{ {
_bundleInfoList.Add(bundleInfo); _bundleInfoList.Add(bundleInfo);
} }
} }
// 重新统计下载信息 // 重新统计下载信息
CalculatDownloaderInfo(); CalculateDownloaderInfo();
} }
/// <summary> /// <summary>

View File

@@ -89,7 +89,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{_playMode} can not support WebGL plateform !"; Error = $"{_playMode} can not support WebGL plateform.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }
@@ -103,7 +103,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !"; Error = $"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform.";
YooLogger.Error(Error); YooLogger.Error(Error);
return; return;
} }

View File

@@ -31,7 +31,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 解析的清单实例 /// 解析的清单实例
/// </summary> /// </summary>
public PackageManifest Manifest { private set; get; } public PackageManifest Manifest { get; private set; }
public DeserializeManifestOperation(IManifestRestoreServices services, byte[] binaryData) public DeserializeManifestOperation(IManifestRestoreServices services, byte[] binaryData)
{ {
@@ -68,7 +68,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Buffer is invalid !"; Error = "Buffer is invalid.";
return; return;
} }
@@ -78,7 +78,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "The manifest file format is invalid !"; Error = "The manifest file format is invalid.";
return; return;
} }
@@ -115,9 +115,9 @@ namespace YooAsset
// 检测配置 // 检测配置
if (Manifest.EnableAddressable && Manifest.LocationToLower) if (Manifest.EnableAddressable && Manifest.LocationToLower)
throw new YooManifestException("Addressable not support location to lower !"); throw new YooManifestException("Addressable not support location to lower.");
if (Manifest.EnableAddressable == false && Manifest.ReplaceAssetPathWithAddress) if (Manifest.EnableAddressable == false && Manifest.ReplaceAssetPathWithAddress)
throw new YooManifestException("Replace asset path with address need enable Addressable !"); throw new YooManifestException("Replace asset path with address need enable Addressable.");
_steps = ESteps.PrepareAssetList; _steps = ESteps.PrepareAssetList;
} }

View File

@@ -40,7 +40,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "The file system parameters is empty !"; Error = "The file system parameters is empty.";
return; return;
} }
@@ -50,7 +50,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "An empty object exists in the list!"; Error = "An empty object exists in the list.";
return; return;
} }
} }
@@ -76,7 +76,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "Failed to create file system instance !"; Error = "Failed to create file system instance.";
return; return;
} }

View File

@@ -102,7 +102,7 @@ namespace YooAsset
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Error($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Error($"{nameof(PreDownloadContentOperation)} status is not succeed.");
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName); return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName);
} }
@@ -116,7 +116,7 @@ namespace YooAsset
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Error($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Error($"{nameof(PreDownloadContentOperation)} status is not succeed.");
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName); return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName);
} }

View File

@@ -335,7 +335,7 @@ namespace YooAsset
{ {
string error; string error;
if (string.IsNullOrEmpty(location)) if (string.IsNullOrEmpty(location))
error = $"The location is null or empty !"; error = $"The location is null or empty.";
else else
error = $"The location is invalid : {location}"; error = $"The location is invalid : {location}";
AssetInfo assetInfo = new AssetInfo(PackageName, error); AssetInfo assetInfo = new AssetInfo(PackageName, error);
@@ -369,8 +369,8 @@ namespace YooAsset
{ {
if (IncludeAssetGUID == false) if (IncludeAssetGUID == false)
{ {
YooLogger.Warning("Package manifest not include asset guid ! Please check asset bundle collector settings."); YooLogger.Warning("Package manifest not include asset guid. Please check asset bundle collector settings.");
AssetInfo assetInfo = new AssetInfo(PackageName, "AssetGUID data is empty !"); AssetInfo assetInfo = new AssetInfo(PackageName, "AssetGUID data is empty.");
return assetInfo; return assetInfo;
} }
@@ -384,7 +384,7 @@ namespace YooAsset
{ {
string error; string error;
if (string.IsNullOrEmpty(assetGUID)) if (string.IsNullOrEmpty(assetGUID))
error = $"The assetGUID is null or empty !"; error = $"The assetGUID is null or empty.";
else else
error = $"The assetGUID is invalid : {assetGUID}"; error = $"The assetGUID is invalid : {assetGUID}";
AssetInfo assetInfo = new AssetInfo(PackageName, error); AssetInfo assetInfo = new AssetInfo(PackageName, error);

View File

@@ -19,10 +19,5 @@ namespace YooAsset
public const string FileVersion = "2025.9.30"; public const string FileVersion = "2025.9.30";
public const string VERSION_2025_8_28 = "2025.8.28"; public const string VERSION_2025_8_28 = "2025.8.28";
public const string VERSION_2025_9_30 = "2025.9.30"; public const string VERSION_2025_9_30 = "2025.9.30";
/// <summary>
/// 版本兼容
/// </summary>
public const bool BackwardCompatible = true;
} }
} }

View File

@@ -8,6 +8,8 @@ namespace YooAsset
{ {
internal static class PackageManifestTools internal static class PackageManifestTools
{ {
private const int MD5HashLength = 32; //MD5的哈希值通常为32个字符
/// <summary> /// <summary>
/// 验证清单文件的二进制数据 /// 验证清单文件的二进制数据
/// </summary> /// </summary>
@@ -19,9 +21,8 @@ namespace YooAsset
return false; return false;
// 注意:兼容俩种验证方式 // 注意:兼容俩种验证方式
// 注意计算MD5的哈希值通常为32个字符
string fileHash; string fileHash;
if (hashValue.Length == 32) if (hashValue.Length == MD5HashLength)
fileHash = HashUtility.BytesMD5(fileData); fileHash = HashUtility.BytesMD5(fileData);
else else
fileHash = HashUtility.BytesCRC32(fileData); fileHash = HashUtility.BytesCRC32(fileData);

View File

@@ -91,7 +91,7 @@ namespace YooAsset
// 检测重复初始化 // 检测重复初始化
if (_initializeOp != null) if (_initializeOp != null)
throw new YooPackageException(PackageName, $"Resource package '{PackageName}' is already initialized!"); throw new YooPackageException(PackageName, $"Resource package '{PackageName}' is already initialized.");
// 开始初始化操作 // 开始初始化操作
_initializeOp = new InitializePackageOperation(this, options); _initializeOp = new InitializePackageOperation(this, options);
@@ -149,7 +149,7 @@ namespace YooAsset
// 注意:强烈建议在更新之前保持加载器为空! // 注意:强烈建议在更新之前保持加载器为空!
if (_resourceManager.HasAnyLoader()) if (_resourceManager.HasAnyLoader())
{ {
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle !"); YooLogger.Warning($"Found loaded bundle before update manifest. Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle.");
} }
var operation = new LoadPackageManifestOperation(_fileSystemHost, options); var operation = new LoadPackageManifestOperation(_fileSystemHost, options);
@@ -891,23 +891,23 @@ namespace YooAsset
{ {
if (InitializeStatus == EOperationStatus.None) if (InitializeStatus == EOperationStatus.None)
{ {
throw new YooPackageException(PackageName, "Resource package not initialized!"); throw new YooPackageException(PackageName, "Resource package not initialized.");
} }
else if (InitializeStatus == EOperationStatus.Processing) else if (InitializeStatus == EOperationStatus.Processing)
{ {
throw new YooPackageException(PackageName, "Resource package initialization not completed!"); throw new YooPackageException(PackageName, "Resource package initialization not completed.");
} }
else if (InitializeStatus == EOperationStatus.Failed) else if (InitializeStatus == EOperationStatus.Failed)
{ {
string error = _initializeOp == null ? string.Empty : _initializeOp.Error; string error = _initializeOp == null ? string.Empty : _initializeOp.Error;
throw new YooPackageException(PackageName, $"Resource package initialization failed! Error: {error}"); throw new YooPackageException(PackageName, $"Resource package initialization failed. Error: {error}");
} }
} }
if (checkActiveManifest) if (checkActiveManifest)
{ {
if (_fileSystemHost.ActiveManifest == null) if (_fileSystemHost.ActiveManifest == null)
throw new YooPackageException(PackageName, "Cannot found active package manifest!"); throw new YooPackageException(PackageName, "Cannot found active package manifest.");
} }
} }

View File

@@ -121,7 +121,7 @@ namespace YooAsset
byte[] bytes = Encoding.UTF8.GetBytes(value); byte[] bytes = Encoding.UTF8.GetBytes(value);
int count = bytes.Length; int count = bytes.Length;
if (count > ushort.MaxValue) if (count > ushort.MaxValue)
throw new FormatException($"Write string length cannot be greater than {ushort.MaxValue} !"); throw new FormatException($"Write string length cannot be greater than {ushort.MaxValue}");
WriteUInt16(Convert.ToUInt16(count)); WriteUInt16(Convert.ToUInt16(count));
WriteBytes(bytes); WriteBytes(bytes);
@@ -137,7 +137,7 @@ namespace YooAsset
{ {
int count = values.Length; int count = values.Length;
if (count > ushort.MaxValue) if (count > ushort.MaxValue)
throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue} !"); throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue}");
WriteUInt16(Convert.ToUInt16(count)); WriteUInt16(Convert.ToUInt16(count));
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@@ -156,7 +156,7 @@ namespace YooAsset
{ {
int count = values.Length; int count = values.Length;
if (count > ushort.MaxValue) if (count > ushort.MaxValue)
throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue} !"); throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue}");
WriteUInt16(Convert.ToUInt16(count)); WriteUInt16(Convert.ToUInt16(count));
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@@ -175,7 +175,7 @@ namespace YooAsset
{ {
int count = values.Length; int count = values.Length;
if (count > ushort.MaxValue) if (count > ushort.MaxValue)
throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue} !"); throw new FormatException($"Write array length cannot be greater than {ushort.MaxValue}");
WriteUInt16(Convert.ToUInt16(count)); WriteUInt16(Convert.ToUInt16(count));
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)

View File

@@ -38,7 +38,7 @@ namespace YooAsset
{ {
if (_isInitialized) if (_isInitialized)
{ {
YooLogger.Warning("YooAssets is already initialized!"); YooLogger.Warning("YooAssets is already initialized.");
return; return;
} }
@@ -102,7 +102,7 @@ namespace YooAsset
{ {
EnsureInitialized(packageName); EnsureInitialized(packageName);
if (ContainsPackage(packageName)) if (ContainsPackage(packageName))
throw new YooPackageException(packageName, $"Resource package {packageName} already existed! Cannot create duplicate packages."); throw new YooPackageException(packageName, $"Resource package {packageName} already existed. Cannot create duplicate packages.");
ResourcePackage package = new ResourcePackage(packageName); ResourcePackage package = new ResourcePackage(packageName);
_packages.Add(packageName, package); _packages.Add(packageName, package);
@@ -160,7 +160,7 @@ namespace YooAsset
if (package.InitializeStatus != EOperationStatus.None) if (package.InitializeStatus != EOperationStatus.None)
{ {
YooLogger.Error($"The resource package {packageName} has not been destroyed, please call the method {nameof(ResourcePackage.DestroyPackageAsync)} to destroy!"); YooLogger.Error($"The resource package {packageName} has not been destroyed, please call the method {nameof(ResourcePackage.DestroyPackageAsync)} to destroy.");
return false; return false;
} }
@@ -189,10 +189,10 @@ namespace YooAsset
private static void EnsureInitialized(string packageName) private static void EnsureInitialized(string packageName)
{ {
if (_isInitialized == false) if (_isInitialized == false)
throw new YooInitializeException($"YooAssets not initialized! Please call {nameof(YooAssets.Initialize)} first."); throw new YooInitializeException($"YooAssets not initialized. Please call {nameof(YooAssets.Initialize)} first.");
if (string.IsNullOrEmpty(packageName)) if (string.IsNullOrEmpty(packageName))
throw new YooInitializeException("Package name cannot be null or empty!"); throw new YooInitializeException("Package name cannot be null or empty.");
} }
#region #region

View File

@@ -24,7 +24,7 @@ namespace YooAsset
#if UNITY_EDITOR #if UNITY_EDITOR
void OnApplicationQuit() void OnApplicationQuit()
{ {
// 说明在编辑器下确保播放被停止时IO类操作被终止。 //注意在编辑器下确保播放被停止时IO类操作被终止。
YooAssets.Destroy(); YooAssets.Destroy();
} }
#endif #endif