Skip to content

Commit 66dd667

Browse files
committedMay 12, 2024
Fixed NullReferenceException on newest Unity versions if VFX Graph package is installed
1 parent da921c2 commit 66dd667

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
 

‎Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ private static string ExtractGUIDFromString( string str )
217217
#endif
218218

219219
#if ASSET_USAGE_VFX_GRAPH
220-
private readonly Func<string, object> vfxResourceGetter = (Func<string, object>) Delegate.CreateDelegate( typeof( Func<string, object> ), typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ).GetMethod( "GetResourceAtPath", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
221-
private readonly MethodInfo vfxResourceContentsGetter = typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ).GetMethod( "GetContents", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
220+
private static Type vfxResourceType => typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ) ?? Array.Find( AppDomain.CurrentDomain.GetAssemblies(), ( assembly ) => assembly.GetName().Name == "UnityEditor.VFXModule" ).GetType( "UnityEditor.VFX.VisualEffectResource" );
221+
private readonly Func<string, object> vfxResourceGetter = (Func<string, object>) Delegate.CreateDelegate( typeof( Func<string, object> ), vfxResourceType.GetMethod( "GetResourceAtPath", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
222+
private readonly MethodInfo vfxResourceContentsGetter = vfxResourceType.GetMethod( "GetContents", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
222223
private readonly MethodInfo vfxSerializableObjectValueGetter = Array.Find( Array.Find( AppDomain.CurrentDomain.GetAssemblies(), ( assembly ) => assembly.GetName().Name == "Unity.VisualEffectGraph.Editor" ).GetType( "UnityEditor.VFX.VFXSerializableObject" ).GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ), ( methodInfo ) => methodInfo.Name == "Get" && !methodInfo.IsGenericMethod );
223224
#endif
224225

‎Plugins/AssetUsageDetector/README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Asset Usage Detector (v2.5.1) =
1+
= Asset Usage Detector (v2.5.2) =
22

33
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
44
E-mail: yasirkula@gmail.com

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.assetusagedetector",
33
"displayName": "Asset Usage Detector",
4-
"version": "2.5.1",
4+
"version": "2.5.2",
55
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
66
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)