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 !

1 Like

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++?

2 Likes

i found the solution,

this is how to do it

You get the asset import data property from the object property then you put it into a asset import data cast (ex: FBX) and then get the filename function from the cast, and there you have it

Asset import types:

1 Like