From 524965aee79ff696d02a2205935c0f8bf5e13f97 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Sat, 7 Oct 2023 20:40:21 +0300 Subject: [PATCH] If an exception is thrown while accessing a variable via reflection, a more detailed error message is logged --- Plugins/AssetUsageDetector/Editor/VariableGetter.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/AssetUsageDetector/Editor/VariableGetter.cs b/Plugins/AssetUsageDetector/Editor/VariableGetter.cs index 03e9e43..87c8fa9 100644 --- a/Plugins/AssetUsageDetector/Editor/VariableGetter.cs +++ b/Plugins/AssetUsageDetector/Editor/VariableGetter.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using System.Text; using UnityEngine; namespace AssetUsageDetectorNamespace @@ -39,7 +40,12 @@ namespace AssetUsageDetectorNamespace } catch( Exception e ) { - Debug.LogException( e ); + StringBuilder sb = Utilities.stringBuilder; + sb.Length = 0; + sb.Append( "Error while getting the value of (" ).Append( IsProperty ? ( (PropertyInfo) variable ).PropertyType : ( (FieldInfo) variable ).FieldType ).Append( ") " ) + .Append( variable.DeclaringType ).Append( "." ).Append( Name ).Append( ": " ).Append( e ); + + Debug.LogError( sb.ToString() ); return null; } }