From efad9fa1583bf312d56ef5c47c368d19385f66b5 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Sat, 7 Oct 2023 20:39:31 +0300 Subject: [PATCH] Muted an exception that is raised while searching "ref struct"s for reference --- .github/README.md | 1 + .../Editor/AssetUsageDetectorSearchFunctions.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/.github/README.md b/.github/README.md index 27105b2..72d7948 100644 --- a/.github/README.md +++ b/.github/README.md @@ -68,5 +68,6 @@ void ReplaceFontUsages( Font from, Font to ) - *static* variables aren't searched - *Resources.Load* usages can't be found +- *ref struct*s can't be searched - *GUIText* materials aren't searched - Textures in *Lens Flares* can't be searched diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs index d62f0cc..8f23ac2 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs @@ -1677,6 +1677,12 @@ namespace AssetUsageDetectorNamespace if( field.FieldType.IsIgnoredUnityType() ) continue; +#if UNITY_2021_2_OR_NEWER + // "ref struct"s can't be accessed via reflection + if( field.FieldType.IsByRefLike ) + continue; +#endif + // Additional filtering for fields: // 1- Ignore "m_RectTransform", "m_CanvasRenderer" and "m_Canvas" fields of Graphic components string fieldName = field.Name; @@ -1711,6 +1717,12 @@ namespace AssetUsageDetectorNamespace if( property.PropertyType.IsIgnoredUnityType() ) continue; +#if UNITY_2021_2_OR_NEWER + // "ref struct"s can't be accessed via reflection + if( property.PropertyType.IsByRefLike ) + continue; +#endif + // Skip properties without a getter function MethodInfo propertyGetter = property.GetGetMethod( true ); if( propertyGetter == null )