From f314fbe4ffe41c9ab6a2be462721871dc1fbc3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=BCleyman=20Yasir=20KULA?= Date: Fri, 2 Mar 2018 23:22:00 +0300 Subject: [PATCH] Bugfix --- Editor/AssetUsageDetector.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/AssetUsageDetector.cs b/Editor/AssetUsageDetector.cs index 89f015b..861706e 100644 --- a/Editor/AssetUsageDetector.cs +++ b/Editor/AssetUsageDetector.cs @@ -230,6 +230,9 @@ namespace AssetUsageDetectorNamespace // Assembly reloading; serialize nodes in a way that Unity can serialize public void OnBeforeSerialize() { + if( references == null ) + return; + if( serializedNodes == null ) serializedNodes = new List( references.Count * 5 ); else @@ -1727,7 +1730,7 @@ namespace AssetUsageDetectorNamespace if( !EditorApplication.isPlaying ) { // Open the scene additively (to access its objects) only if it seems to contain some references to searched object(s) - if( searchedType != SearchedType.SceneObject && !AssetDatabase.LoadAssetAtPath( scenePath ).HasAnyReferenceTo( assetsSet ) ) + if( searchedType == SearchedType.Asset && !AssetDatabase.LoadAssetAtPath( scenePath ).HasAnyReferenceTo( assetsSet ) ) return; scene = EditorSceneManager.OpenScene( scenePath, OpenSceneMode.Additive ); @@ -1859,7 +1862,7 @@ namespace AssetUsageDetectorNamespace } // Search the Object in detail only if EditorUtility.CollectDependencies returns a reference - if( searchedType != SearchedType.SceneObject && !unityObject.HasAnyReferenceTo( assetsSet ) ) + if( searchedType == SearchedType.Asset && !unityObject.HasAnyReferenceTo( assetsSet ) ) { searchedObjects.Add( objHash, null ); return null; @@ -2418,4 +2421,4 @@ namespace AssetUsageDetectorNamespace return true; } } -} \ No newline at end of file +}