Unreal Engine - How to save a transient texture variable into Content Browser at runtime?

Hi, I am ***** from *******, I have just one year working with unreal engine using only blueprints because C++ language I have not the knowledge.

I explain to you my problem, My android app runs correctly to bring images from the phone gallery at runtime then apply to a static mesh, then the user have the option to save your session in order to reload before and continue playing, but the problem is that texture doesn’t save and can´t be reloaded in the static mesh. I’ve been reading on the internet and the problem is because it has been assigned a “transient” property.

On the internet people say using C++ it’s possible to get this texture that alredy comes from gallery phone without no problem at runtime and save into CONTENT BROWSER in unreal engine at runtime, once it is in the content browser this texture I can SAVE and RELOAD it with normality.

I found some information on the internet that just lets me save a COLOR into CONTENT BROWSER at runtime, but I need to save an image from a gallery phone into a CONTENT BROWSER, all at RUNTIME. Please I need some help.


const std::size_t width = 250;
const std::size_t height = 250;

TArray Pixels;
Pixels.Init(FColor(0, 0, 255, 255), width * height);

FString PackageName = TEXT(“/Game/MobileStarterContent/Textures/”);
FString TextureName = TEXT(“TexturaAndres4”);
PackageName += TextureName;
UPackage* Package = CreatePackage(NULL, *PackageName);
Package->FullyLoad();

UTexture2D* res = NewObject(Package, *TextureName, RF_Public | RF_Standalone | RF_MarkAsRootSet);

res->AddToRoot();
res->SRGB = 0;
res->MipGenSettings = TMGS_NoMipmaps;

res->PlatformData = new FTexturePlatformData(); // Then we initialize the PlatformData
res->PlatformData->SizeX = width;
res->PlatformData->SizeY = height;
res->PlatformData->PixelFormat = EPixelFormat::PF_R8G8B8A8;
res->UpdateResource();

// // Allocate first mipmap.
FTexture2DMipMap* Mip = new FTexture2DMipMap();
res->PlatformData->Mips.Add(Mip);
Mip->SizeX = width;
Mip->SizeY = height;

Mip->BulkData.Lock(LOCK_READ_WRITE);
uint8* TextureData = static_cast<uint8*>(Mip->BulkData.Realloc(width * height * sizeof(FColor)));
FMemory::Memcpy(TextureData, Pixels.GetData(), width * height * sizeof(FColor));
Mip->BulkData.Unlock();

// Apply Texture changes to GPU memory
res->UpdateResource();

res->Source.Init(
width,
height,
1, 1, ETextureSourceFormat::TSF_RGBA8, reinterpret_cast<uint8*>(Pixels.GetData()));

res->UpdateResource();
Package->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(res);

FString PackageFileName = FPackageName::LongPackageNameToFilename(PackageName, FPackageName::GetAssetPackageExtension());
bool bSaved = UPackage::SavePackage(Package, res, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone, *PackageFileName, GError, nullptr, true, true, SAVE_NoError);
check(bSaved)

I don’t have experience with Android, but I think you need to save the texture on disk as a regular image (jpeg, png, …). And then you can load it from disk.

There is no content browser at runtime.