Editor Scripting: How to get names of all textures that are sampled in a material?

I’m making a helper widget for myself.
I need to get all textures (names and paths, or as an object) of one material.
I’ve tried everything (and c++ too) and had no success. Any ideas? (C++, python, Blueprints)

maybe you can refer to “Reference Viewer”

293073-1.png

][3]

Here is my solution:

FLinearColor GetMaterialAverageColor(UMaterial* mat)
{
	FLinearColor c;
	if (mat)
	{
		int32 Result = 0;
		{
			Result = mat->Expressions.Num();
			for (int i = 0; i < Result; i++) {
				FName n = mat->Expressions[i]->GetFName();
				UE_LOG(LogTemp, Warning, TEXT("expression name: %s"), *n.ToString());
				if (n.ToString().Contains("MaterialExpressionTextureSample_"))
				{
					UObject* o = mat->Expressions[i]->GetReferencedTexture();
					if (o) {
						FString n2 = o->GetClass()->GetName();
						FString p = o->GetPathName();
						UE_LOG(LogTemp, Warning, TEXT("GetReferencedTexture GetName: %s"), *n2);
						UE_LOG(LogTemp, Warning, TEXT("GetReferencedTexture Path: %s"), *p);
						c = GetTextureAverageColor((UTexture2D*)o);
						UE_LOG(LogTemp, Warning, TEXT("color: %s"), *c.ToString());
						break;
					}
					FName np = mat->Expressions[i]->GetParameterName();
					UE_LOG(LogTemp, Warning, TEXT("GetParameterName: %s"), *np.ToString());

				}
			}
		}
	}
		return c;
}