I’m creating texture data at runtime and applying them to a texture variable like so:
UPROPERTY() UTexture2D* mainNormalTexture;
........
........
mainNormalTexture = UTexture2D::CreateTransient(normalTextureWidth, normalTextureHeight, PF_B8G8R8A8);
mainNormalTexture->AddToRoot();
mainNormalTexture->AddressX = TextureAddress::TA_Clamp;
mainNormalTexture->AddressY = TextureAddress::TA_Clamp;
mainNormalTexture->Filter = TextureFilter::TF_Nearest;
........
uint8* TextureData = (uint8*)mainNormalTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(TextureData, normalTextureData.GetData(), sizeof(FColor) * normalTextureWidth * normalTextureHeight);
mainNormalTexture->PlatformData->Mips[0].BulkData.Unlock();
mainNormalTexture->UpdateResource();
An issue I’m running into is when I hit play and stop in the editor a number of times I get a red error message telling me Texture Streaming Pool Over Budget. I’m guessing this is because the editor is not cleaning up something when I press stop. I’ve tried to fix this with the following:
void AMyPlayerController::EndPlay(const EEndPlayReason::Type EndPlayReason) {
Super::EndPlay(EndPlayReason);
mainNormalTexture->RemoveFromRoot();
mainNormalTexture = nullptr;
}
However it doesn’t make a difference. When I hit play about 5 times the error still pops up.
Any way to clear this texture pool between sessions?