Compare commits

...

2 Commits

Author SHA1 Message Date
Süleyman Yasir KULA f4129574fb - Custom meshes used in ParticleSystem's Renderer module weren't included in the search, fixed
- Fix an exception that occurred when searching an Assembly Definition File's references if one of its References was missing
2020-10-01 13:43:23 +03:00
Süleyman Yasir KULA 7738da9d19 "Search for References-Include Children" didn't include inactive child objects in search, fixed 2020-09-23 23:12:47 +03:00
5 changed files with 25 additions and 17 deletions
@@ -548,7 +548,7 @@ namespace AssetUsageDetectorNamespace
catch( Exception e )
{
StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 500 );
sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine();
sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine().Append( e ).AppendLine();
if( callStack.Count > 0 )
{
sb.AppendLine( "Stack contents: " );
@@ -575,9 +575,6 @@ namespace AssetUsageDetectorNamespace
sb.Append( obj.name ).Append( " (" ).Append( obj.GetType() ).AppendLine( ")" );
}
sb.AppendLine();
sb.Append( e ).AppendLine();
Debug.LogError( sb.ToString() );
try
@@ -619,7 +616,7 @@ namespace AssetUsageDetectorNamespace
if( shouldOpenPrefabStageWithoutContext )
#endif
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
}
#endif
}
@@ -382,6 +382,14 @@ namespace AssetUsageDetectorNamespace
if( objectsToSearchSet.Contains( script ) )
referenceNode.AddLinkTo( GetReferenceNode( script ) );
}
else if( component is ParticleSystemRenderer )
{
// Search ParticleSystemRenderer's custom meshes for references (they aren't searched by SerializedObject, unfortunately)
Mesh[] meshes = new Mesh[( (ParticleSystemRenderer) component ).meshCount];
int meshCount = ( (ParticleSystemRenderer) component ).GetMeshes( meshes );
for( int i = 0; i < meshCount; i++ )
referenceNode.AddLinkTo( SearchObject( meshes[i] ), "Custom particle mesh" );
}
else if( searchRenderers && component is Renderer )
{
// If an asset is a shader, texture or material, and this component is a Renderer,
@@ -392,7 +400,7 @@ namespace AssetUsageDetectorNamespace
}
else if( component is Animation )
{
// If this component is an Animation, search its animation clips for references
// Search animation clips for references
foreach( AnimationState anim in (Animation) component )
referenceNode.AddLinkTo( SearchObject( anim.clip ) );
@@ -401,7 +409,7 @@ namespace AssetUsageDetectorNamespace
}
else if( component is Animator )
{
// If this component is an Animator, search its animation clips for references (via AnimatorController)
// Search animation clips for references (via AnimatorController)
referenceNode.AddLinkTo( SearchObject( ( (Animator) component ).runtimeAnimatorController ) );
// Search the objects that are animated by this Animator component for references
@@ -410,7 +418,7 @@ namespace AssetUsageDetectorNamespace
#if UNITY_2017_2_OR_NEWER
else if( component is Tilemap )
{
// If this component is a Tilemap, search its tiles for references
// Search the tiles for references
TileBase[] tiles = new TileBase[( (Tilemap) component ).GetUsedTilesCount()];
( (Tilemap) component ).GetUsedTilesNonAlloc( tiles );
@@ -424,7 +432,7 @@ namespace AssetUsageDetectorNamespace
#if UNITY_2017_1_OR_NEWER
else if( component is PlayableDirector )
{
// If this component is a PlayableDirectory, search its PlayableAsset's scene bindings for references
// Search the PlayableAsset's scene bindings for references
PlayableAsset playableAsset = ( (PlayableDirector) component ).playableAsset;
if( playableAsset != null && !playableAsset.Equals( null ) )
{
@@ -536,7 +544,7 @@ namespace AssetUsageDetectorNamespace
{
Object defaultValue = scriptImporter.GetDefaultReference( variables[i].name );
if( objectsToSearchSet.Contains( defaultValue ) )
referenceNode.AddLinkTo( GetReferenceNode( defaultValue ), "Default Variable Value: " + variables[i].name );
referenceNode.AddLinkTo( GetReferenceNode( defaultValue ), "Default variable value: " + variables[i].name );
}
}
@@ -719,9 +727,12 @@ namespace AssetUsageDetectorNamespace
#else
string assemblyPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName( assemblyDefinitionFile.references[i] );
#endif
Object searchedAssemblyDefinitionFile;
if( assemblyDefinitionFilesToSearch.TryGetValue( assemblyPath, out searchedAssemblyDefinitionFile ) )
referenceNode.AddLinkTo( GetReferenceNode( searchedAssemblyDefinitionFile ), "Referenced Assembly" );
if( !string.IsNullOrEmpty( assemblyPath ) )
{
Object searchedAssemblyDefinitionFile;
if( assemblyDefinitionFilesToSearch.TryGetValue( assemblyPath, out searchedAssemblyDefinitionFile ) )
referenceNode.AddLinkTo( GetReferenceNode( searchedAssemblyDefinitionFile ), "Referenced Assembly" );
}
}
}
@@ -153,8 +153,8 @@ namespace AssetUsageDetectorNamespace
}
// Show the menu item only if there is a selection in the Editor
[MenuItem( "GameObject/Search for References", validate = true )]
[MenuItem( "GameObject/Search for References (Include Children)", validate = true )]
[MenuItem( "GameObject/Search for References/This Object Only", validate = true )]
[MenuItem( "GameObject/Search for References/Include Children", validate = true )]
[MenuItem( "Assets/Search for References", validate = true )]
private static bool SearchSelectedAssetReferencesValidate( MenuCommand command )
{
@@ -65,7 +65,7 @@ namespace AssetUsageDetectorNamespace
// If this is a scene object, add its child objects to the sub-assets list
// but don't include them in the search by default
Transform goTransform = go.transform;
Transform[] children = go.GetComponentsInChildren<Transform>();
Transform[] children = go.GetComponentsInChildren<Transform>( true );
for( int i = 0; i < children.Length; i++ )
{
if( ReferenceEquals( children[i], goTransform ) )
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "com.yasirkula.assetusagedetector",
"displayName": "Asset Usage Detector",
"version": "1.8.6",
"version": "1.8.8",
"description": "This editor extension helps you figure out at which places an asset or GameObject is used, i.e. lists the objects that refer to the asset. It is possible to search for references in the Assets folder (Project view) and/or in the scene(s) of your project. You can also search for references while in Play mode!"
}