I’m trying to download and display some images on my UI.
I don’t want to redownload the images every time I run the game.
hence I want to export the downloaded Image to Disk after the first time and then reuse it.
But “Export To Disk” node is not working
So I tried to use “Export Texture2D” instead. It works with normal Texture 2D inputs, but the “Download Image” node returns a Texture 2DDynamic, which doesn’t work with the “Export Texture2D” node.
After spending some time trying to convert a Texture2D into a Texture2DDynamic and vice-versa. I figured out that it was not possible directly, that is because both classes inherit from the same class “UTexture”. Then I tried to create a new Texture2D using the values from Texture2DDynamic, I had problems but it seems possible on c++, on blueprints on the other side, it doesn’t look like it’s going to be easy.
So a new approach came into mind, what if we try to parse the Texture of the Brush? Something like this
Thanks for the insight
I tried to parse the Texture of the Brush like that, but the Texture2D Cast Failed.
I’ll look into creating a new Texture2D in C++
FTexture2DDynamicCreateInfo Texture2DDynamicCreateInfo;
Texture2DDynamicCreateInfo.Filter = Texture->Filter;
Texture2DDynamicCreateInfo.Format = Texture->GetPixelFormat();
Texture2DDynamicCreateInfo.bIsResolveTarget = false;
Texture2DDynamicCreateInfo.bSRGB = Texture->SRGB;
DynamicTexture = UTexture2DDynamic::Create(Texture->GetSizeX(), Texture->GetSizeY(),
Texture2DDynamicCreateInfo);
DynamicTexture->SetResource(Texture->GetResource());
DynamicTexture->SetFlags(Texture->GetFlags());
DynamicTexture->SetLinker(Texture->GetLinker(), Texture->GetLinkerIndex(), true);
DynamicTexture->SetExternalPackage(Texture->GetExternalPackage());
DynamicTexture->SetLightingGuid();
NewTexture = UTexture2D::CreateTransient(DynamicTexture->SizeX, DynamicTexture->SizeY, DynamicTexture->Format);
NewTexture->SetResource(DynamicTexture->GetResource());
NewTexture->SetFlags(DynamicTexture->GetFlags());
NewTexture->SetLinker(DynamicTexture->GetLinker(), DynamicTexture->GetLinkerIndex(), true);
NewTexture->SetExternalPackage(DynamicTexture->GetExternalPackage());
NewTexture->SetLightingGuid();
// NewTexture should be equal or similar to Texture
I’ve been trying to convert a Texture2D into a Texture2DDynamic and then create a new Texture2D from that Texture2DDynamic, but I’m not that familiar with textures and how they are built. This compiles, but whenever you want to look at it on the editor (select the actor in the world outliner) it crashes. I suspect it should be something similar but with the knowledge of the posts I linked before.