From f6a999f0535b08ec5f8e2ccd82152682f7fd6280 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Sun, 7 May 2023 21:37:38 +0300 Subject: [PATCH] Fixed an exception that occurs when a VFX Graph window is open and the open VFX Graph asset is searched for references (there may be other similar edge cases, as well) --- .../AssetUsageDetector/Editor/AssetUsageDetector.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs index cbe2b4d..f1ac18a 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs @@ -985,9 +985,13 @@ namespace AssetUsageDetectorNamespace if( obj == null || obj.Equals( null ) ) return null; - // Avoid recursion (which leads to stackoverflow exception) using a stack - if( callStack.ContainsFast( obj ) ) - return null; + // Avoid recursion (which leads to stackoverflow exception) using a stack (initially, I was using callStack.ContainsFast + // here but it returned false for objects that do exist in the call stack if VFX Graph window was open) + for( int i = callStack.Count - 1; i >= 0; i-- ) + { + if( callStack[i].Equals( obj ) ) + return null; + } bool searchingSourceAsset = searchingSourceAssets && ReferenceEquals( currentSearchedObject, obj );