Unresolved external symbol FTexturePlatformData

Hey there !

I’m following this topic and my code is nearly identical to what @PEYMAAN has posted.

How to create textures at runtime and assign them to a mesh? - #3 by PEYMAN

	UTexture2D* CustomTexture = UTexture2D::CreateTransient(32, 32);
	FTexturePlatformData** PlatformData = CustomTexture->GetRunningPlatformData();
	FTexture2DMipMap FirstMip = (*PlatformData)->Mips[0];
	FByteBulkDataOld ImageData = FirstMip.BulkData;
	uint8* RawImageData = static_cast<uint8*>(ImageData.Lock(LOCK_READ_WRITE));
	
	int TextureSize = 32 * 32;
	for(auto i = 0; i < TextureSize; i += 4)
	{
		RawImageData[i] = 255;
	}

	ImageData.Unlock();
	CustomTexture->UpdateResource();

However when I try to compile I get this error:

unresolved external symbol “public: virtual struct FTexturePlatformData * * __cdecl UTexture2D::GetRunningPlatformData(void)” (?GetRunningPlatformData@UTexture2D@@UEAAPEAPEAUFTexturePlatformData@@anonymous_user_9674a66c) referenced in function “public: void __cdecl AThreadActor::SwapTexture(void)” (?SwapTexture@AThreadActor@@QEAAXXZ)

Does anyone know how to resolve this ? I’m using UE5 Preview 2.

Alright, I think I found the way that works, I just needed to rearrange the code a little bit.

	UTexture2D* CustomTexture = UTexture2D::CreateTransient(32, 32);
	uint8* RawImageData = static_cast<uint8*>(CustomTexture->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_WRITE));

	constexpr int TextureSize = 32 * 32 * 4;
	for(auto i = 0; i < TextureSize; i += 4)
	{
		RawImageData[i] = 255;
		RawImageData[i + 1] = 0;
		RawImageData[i + 2] = 0;
		RawImageData[i + 3] = 1;
	}

	CustomTexture->GetPlatformData()->Mips[0].BulkData.Unlock();
	CustomTexture->UpdateResource();
1 Like