How to get source file path from UTexture?

I get an UTexture object, it is loaded from a picture, for example the path is D:/1.jpg.

I want to know the function to get the path with C++

Because the SourceFilePath_DEPRECATED variable is “DEPRECATED” in UE4.23 !

SourceFilePath_DEPRECATED has replaced by UAssetImportData AssetImportData*

290389-1223.png

it is my code to get the souce path:

if (NULL != TestTexture && NULL != TestTexture->AssetImportData)
{
	const FAssetImportInfo& AssetImportInfo = TestTexture->AssetImportData->SourceData;

	if (AssetImportInfo.SourceFiles.Num() >= 1)
	{
		FString SourceFilePath = AssetImportInfo.SourceFiles[0].RelativeFilename;
		UE_LOG(LogTemp, Warning, TEXT("source file path is %s"), *SourceFilePath);
	}
}
1 Like

Any way to return file path without using C++?