mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 14:32:37 +08:00
Materials instantiated (cloned) at runtime are now searched correctly
This commit is contained in:
@@ -571,6 +571,23 @@ namespace AssetUsageDetectorNamespace
|
||||
referenceNode.RemoveLink( i );
|
||||
}
|
||||
|
||||
// At runtime, Textures assigned to clone materials can't be searched with reflection, search them manually here
|
||||
if( searchTextureReferences && isInPlayMode && !AssetDatabase.Contains( material ) )
|
||||
{
|
||||
Shader shader = material.shader;
|
||||
int shaderPropertyCount = ShaderUtil.GetPropertyCount( shader );
|
||||
for( int i = 0; i < shaderPropertyCount; i++ )
|
||||
{
|
||||
if( ShaderUtil.GetPropertyType( shader, i ) == ShaderUtil.ShaderPropertyType.TexEnv )
|
||||
{
|
||||
string propertyName = ShaderUtil.GetPropertyName( shader, i );
|
||||
Texture assignedTexture = material.GetTexture( propertyName );
|
||||
if( objectsToSearchSet.Contains( assignedTexture ) )
|
||||
referenceNode.AddLinkTo( GetReferenceNode( assignedTexture ), "Shader property: " + propertyName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return referenceNode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user