I’m sorry if this question is dumb, but I’ve been googling for 2 days now and wasn’t able to get it to work. I’m using the HTTP module to download an image and create a texture dynamically at runtime, using [FONT=Courier New]UTexture2D::CreateTransient(). I’d then like to update a [FONT=Courier New]PaperSpriteActor to show this texture. After a lot of messing around, I first created a [FONT=Courier New]DynamicPaperSprite that simply adds one method [FONT=Courier New]SetTexture to [FONT=Courier New]PaperSprite:
void UDynamicPaperSprite::SetTexture(UTexture2D* Texture)
{
SourceTexture = Texture;
SourceDimension.Set(Texture->GetSizeX(), Texture->GetSizeY());
SourceUV.Set(0, 0);
PixelsPerUnrealUnit = 1.0f;
PostLoad();
GEngine->AddOnScreenDebugMessage(-1, 20.0f, FColor::Red, FString(TEXT("Done DynamicPaperSprite->SetTexture")));
}
Then, on my [FONT=Courier New]DynamicPaperSpriteActor, I do this:
void ADynamicPaperSpriteActor::UpdateTexture(UTexture2D* Texture)
{
UPaperRenderComponent* Render = Super::GetRenderComponent();
Render->SetMobility(EComponentMobility::Stationary);
UDynamicPaperSprite* Sprite = dynamic_cast<UDynamicPaperSprite*>(Render->GetSprite());
if (!Sprite)
Sprite = NewObject<UDynamicPaperSprite>();
Sprite->SetTexture(Texture);
Render->SetSprite(Sprite);
}
When I run this, the game successfully sets up the new sprite on my actor. However, the created sprite is completely blank. I’m sure the image I’m downloading is not blank, I’ve tested this.
Any ideas?