From d5a4b3365f15f529d92547fa1aa58ab7e8b616f7 Mon Sep 17 00:00:00 2001
From: hevinci <hevinci@hotmail.com>
Date: Wed, 20 Jul 2022 10:57:56 +0800
Subject: [PATCH] Update YooAssets.cs

---
 Assets/YooAsset/Runtime/YooAssets.cs | 84 ++++++++++++++++------------
 1 file changed, 48 insertions(+), 36 deletions(-)

diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs
index 0fa3b4e..b7dc14c 100644
--- a/Assets/YooAsset/Runtime/YooAssets.cs
+++ b/Assets/YooAsset/Runtime/YooAssets.cs
@@ -404,10 +404,7 @@ namespace YooAsset
 			DebugCheckInitialize();
 			AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
 			if (assetInfo.IsInvalid)
-			{
-				YooLogger.Warning(assetInfo.Error);
 				return false;
-			}
 
 			BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
 			if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
@@ -469,38 +466,7 @@ namespace YooAsset
 		}
 		#endregion
 
-		#region 场景加载
-		/// <summary>
-		/// 异步加载场景
-		/// </summary>
-		/// <param name="location">场景的定位地址</param>
-		/// <param name="sceneMode">场景加载模式</param>
-		/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
-		/// <param name="priority">优先级</param>
-		public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
-		{
-			DebugCheckInitialize();
-			AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
-			var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
-			return handle;
-		}
-
-		/// <summary>
-		/// 异步加载场景
-		/// </summary>
-		/// <param name="assetInfo">场景的资源信息</param>
-		/// <param name="sceneMode">场景加载模式</param>
-		/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
-		/// <param name="priority">优先级</param>
-		public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
-		{
-			DebugCheckInitialize();
-			var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
-			return handle;
-		}
-		#endregion
-
-		#region 资源加载
+		#region 原生文件
 		/// <summary>
 		/// 异步获取原生文件
 		/// </summary>
@@ -521,6 +487,8 @@ namespace YooAsset
 		public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
 		{
 			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
 			return GetRawFileInternal(assetInfo, copyPath);
 		}
 
@@ -529,7 +497,6 @@ namespace YooAsset
 		{
 			if (assetInfo.IsInvalid)
 			{
-				YooLogger.Warning(assetInfo.Error);
 				RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
 				OperationSystem.StartOperaiton(operation);
 				return operation;
@@ -570,6 +537,39 @@ namespace YooAsset
 		}
 		#endregion
 
+		#region 场景加载
+		/// <summary>
+		/// 异步加载场景
+		/// </summary>
+		/// <param name="location">场景的定位地址</param>
+		/// <param name="sceneMode">场景加载模式</param>
+		/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
+		/// <param name="priority">优先级</param>
+		public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
+		{
+			DebugCheckInitialize();
+			AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
+			var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
+			return handle;
+		}
+
+		/// <summary>
+		/// 异步加载场景
+		/// </summary>
+		/// <param name="assetInfo">场景的资源信息</param>
+		/// <param name="sceneMode">场景加载模式</param>
+		/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
+		/// <param name="priority">优先级</param>
+		public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
+		{
+			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
+			var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
+			return handle;
+		}
+		#endregion
+
 		#region 资源加载
 		/// <summary>
 		/// 同步加载资源对象
@@ -578,6 +578,8 @@ namespace YooAsset
 		public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
 		{
 			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
 			return LoadAssetInternal(assetInfo, true);
 		}
 
@@ -613,6 +615,8 @@ namespace YooAsset
 		public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
 		{
 			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
 			return LoadAssetInternal(assetInfo, false);
 		}
 
@@ -658,6 +662,8 @@ namespace YooAsset
 		public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
 		{
 			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
 			return LoadSubAssetsInternal(assetInfo, true);
 		}
 
@@ -693,6 +699,8 @@ namespace YooAsset
 		public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
 		{
 			DebugCheckInitialize();
+			if (assetInfo.IsInvalid)
+				YooLogger.Warning(assetInfo.Error);
 			return LoadSubAssetsInternal(assetInfo, false);
 		}
 
@@ -1056,6 +1064,10 @@ namespace YooAsset
 		#endregion
 
 		#region 私有方法
+		/// <summary>
+		/// 资源定位地址转换为资源信息类,失败时内部会发出错误日志。
+		/// </summary>
+		/// <returns>如果转换失败会返回一个无效的资源信息类</returns>
 		private static AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
 		{
 			DebugCheckLocation(location);