diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs index 8a944a5..04aafb9 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs @@ -216,6 +216,7 @@ namespace AssetUsageDetectorNamespace { typeof( AnimatorStateTransition ), SearchAnimatorStateTransition }, { typeof( BlendTree ), SearchBlendTree }, { typeof( AnimationClip ), SearchAnimationClip }, + { typeof( TerrainData ), SearchTerrainData }, #if UNITY_2017_1_OR_NEWER { typeof( SpriteAtlas ), SearchSpriteAtlas }, #endif @@ -966,6 +967,14 @@ namespace AssetUsageDetectorNamespace return referenceNode; } + // TerrainData's properties like tree/detail/layer definitions aren't exposed to SerializedObject so use reflection instead + private ReferenceNode SearchTerrainData( Object unityObject ) + { + ReferenceNode referenceNode = PopReferenceNode( unityObject ); + SearchVariablesWithReflection( referenceNode ); + return referenceNode; + } + #if UNITY_2017_1_OR_NEWER private ReferenceNode SearchSpriteAtlas( Object unityObject ) { @@ -1626,6 +1635,11 @@ namespace AssetUsageDetectorNamespace // Ignore "meshFilter" property of TextMeshPro and TMP_SubMesh components because this property adds a MeshFilter component to the object if it doesn't exist else if( propertyName == "meshFilter" && ( currType.Name == "TextMeshPro" || currType.Name == "TMP_SubMesh" ) ) continue; + // Ignore "users" property of TerrainData because it returns the Terrains in the scene that use that TerrainData. This causes issues with callStack because TerrainData + // is already in callStack when Terrains are searched via "users" property of it and hence, Terrain->TerrainData references for that TerrainData can't be found in scenes + // (this is how callStack works, it prevents searching an object if it's already in callStack to avoid infinite recursion) + else if( propertyName == "users" && typeof( TerrainData ).IsAssignableFrom( currType ) ) + continue; else { VariableGetVal getter = property.CreateGetter(); diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs index 85501b8..786fbe9 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs @@ -461,7 +461,10 @@ namespace AssetUsageDetectorNamespace GUILayout.Label( ". . . Search in progress or something went wrong (check console) . . ." ); if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) ) + { ReturnToSetupPhase(); + GUIUtility.ExitGUI(); + } } else if( currentPhase == Phase.Setup ) { @@ -576,7 +579,10 @@ namespace AssetUsageDetectorNamespace GUI.enabled = true; if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) ) + { ReturnToSetupPhase(); + GUIUtility.ExitGUI(); + } if( searchResult == null ) { diff --git a/package.json b/package.json index 7732e81..8ca9d03 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.assetusagedetector", "displayName": "Asset Usage Detector", - "version": "2.2.1", + "version": "2.2.2", "documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector", "changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases", "licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",