Hi, I am receiving Images through network (jpg, png, …). Then I am trying to add those has texture that I will be able to use for material for staticmesh. here is the code I wrote trying to see in the editor the result but I see nothing.
TArray<uint8> buffer;
buffer.SetNum(pair.Value.data_size);
memcpy(buffer.GetData(), pair.Value.payload, pair.Value.data_size); //payload is png binary
UTexture2D* tex = FImageUtils::ImportBufferAsTexture2D(buffer);
FString name = FString(TEXT("Textures_network")) ;
FString path = FString(TEXT("/Game/Textures/Generated/"));
FString packageName = path + name;
UPackage* package = CreatePackage(*packageName);
tex->UpdateResource();
#if WITH_EDITOR
tex->PostEditChange();
#endif
tex->MarkPackageDirty();
package->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(tex);
Is there something I do wrong?
Thanks for your time