Skip to content

Commit cb4454b

Browse files
committed
- Terrains are now searched properly
- Fixed an error on latest Unity versions when clicking the "Reset Search" button
1 parent dfb8541 commit cb4454b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ private void InitializeSearchFunctionsData( Parameters searchParameters )
216216
{ typeof( AnimatorStateTransition ), SearchAnimatorStateTransition },
217217
{ typeof( BlendTree ), SearchBlendTree },
218218
{ typeof( AnimationClip ), SearchAnimationClip },
219+
{ typeof( TerrainData ), SearchTerrainData },
219220
#if UNITY_2017_1_OR_NEWER
220221
{ typeof( SpriteAtlas ), SearchSpriteAtlas },
221222
#endif
@@ -966,6 +967,14 @@ private ReferenceNode SearchAnimationClip( Object unityObject )
966967
return referenceNode;
967968
}
968969

970+
// TerrainData's properties like tree/detail/layer definitions aren't exposed to SerializedObject so use reflection instead
971+
private ReferenceNode SearchTerrainData( Object unityObject )
972+
{
973+
ReferenceNode referenceNode = PopReferenceNode( unityObject );
974+
SearchVariablesWithReflection( referenceNode );
975+
return referenceNode;
976+
}
977+
969978
#if UNITY_2017_1_OR_NEWER
970979
private ReferenceNode SearchSpriteAtlas( Object unityObject )
971980
{
@@ -1626,6 +1635,11 @@ private VariableGetterHolder[] GetFilteredVariablesForType( Type type )
16261635
// Ignore "meshFilter" property of TextMeshPro and TMP_SubMesh components because this property adds a MeshFilter component to the object if it doesn't exist
16271636
else if( propertyName == "meshFilter" && ( currType.Name == "TextMeshPro" || currType.Name == "TMP_SubMesh" ) )
16281637
continue;
1638+
// Ignore "users" property of TerrainData because it returns the Terrains in the scene that use that TerrainData. This causes issues with callStack because TerrainData
1639+
// 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
1640+
// (this is how callStack works, it prevents searching an object if it's already in callStack to avoid infinite recursion)
1641+
else if( propertyName == "users" && typeof( TerrainData ).IsAssignableFrom( currType ) )
1642+
continue;
16291643
else
16301644
{
16311645
VariableGetVal getter = property.CreateGetter();

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ private void OnGUI()
461461
GUILayout.Label( ". . . Search in progress or something went wrong (check console) . . ." );
462462

463463
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
464+
{
464465
ReturnToSetupPhase();
466+
GUIUtility.ExitGUI();
467+
}
465468
}
466469
else if( currentPhase == Phase.Setup )
467470
{
@@ -576,7 +579,10 @@ private void OnGUI()
576579
GUI.enabled = true;
577580

578581
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
582+
{
579583
ReturnToSetupPhase();
584+
GUIUtility.ExitGUI();
585+
}
580586

581587
if( searchResult == null )
582588
{

package.json

Lines changed: 1 addition & 1 deletion
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.2.1",
4+
"version": "2.2.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)