From 418536ded16bfb4d7b7abc6dc3dac244e2db5bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Tue, 13 Aug 2024 19:13:26 +0800 Subject: [PATCH] perf : check collect asset type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 检测收集的资源类型是否有效 --- Assets/YooAsset/Editor/Common/AssetInfo.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/YooAsset/Editor/Common/AssetInfo.cs b/Assets/YooAsset/Editor/Common/AssetInfo.cs index e0cc325..f9642eb 100644 --- a/Assets/YooAsset/Editor/Common/AssetInfo.cs +++ b/Assets/YooAsset/Editor/Common/AssetInfo.cs @@ -42,6 +42,12 @@ namespace YooAsset.Editor AssetPath = assetPath; AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath); AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath); + + // 注意:如果资源文件损坏或者实例化关联脚本丢失,获取的资源类型会无效! + if (AssetType == null) + { + throw new Exception($"Found invalid asset : {AssetPath}"); + } } ///