Possible to serialize a procedural UTexture2D inline *without* creating a separate Asset in the project?

I have a component that creates a dynamically-sized procedural texture based on a buffer of data it generates on the CPU.
Creating and rendering to the texture at runtime works just fine via UTexture2D::CreateTransient and RHIUpdateTexture2D
Blueprints are able to read it and everything works great.

However:
I’d also like to be able to pre-generate the texture whenever certain parameters change in PostEditChangeProperty and thus have the texture ready to go when the game begins instead of only serializing out the raw source buffer as a TArray<uint8> and then calling UTexture2D::CreateTransient and RHIUpdateTexture2D in something like InitializeComponent.

I know I can use stuff like FAssetRegistryModule et al to create a new texture asset and save it in the content folders, but I’d like to not pollute the content folder with a bunch of data textures. I’d instead like the owning object to fully serialize it inline within its own package.

So far, what I’ve observed is that if I expose a UTexture2D like so:

UPROPERTY(BlueprintReadOnly) // no Transient
UTexture2D* Tex;

… and something like this in PostEditChangeProperty():

...
int Width = 64;
int Height = 64;

Tex = NewObject<UTexture2D>(this, TEXT("Tex"));
Tex->Source.Init(Width, Height, /*NumSlices=*/ 1, /*NumMips=*/ 1, TSF_BGRA8);
FColor* MipData = reinterpret_cast<FColor*>(Tex->Source.LockMip(0));

// dummy data
for (int i = 0; i < Width * Height; ++i)
{
	MipData[i] = FColor::Green;
}
Tex->Source.UnlockMip(0);
Tex->DeferCompression = true;

Tex->UpdateResource();
...

I get an error when trying to save the scene with my object in it:

Graph is linked to private object(s) in an external package.
External Object(s):
Tex
AssetImportData

so anyway, I’m curious if anyone has any ideas how to go about this, or if there’s some other UTexture2D-compatible structure I could use (I ultimately need to send it to a Texture Sampler in Niagara). I tried UTextureRenderTarget2D and its equivalent methods, but ended up with the same error at the end.

I ran into this problem with a UTextureRenderTarget2D and was able to work around it by setting its AssetImportData property to nullptr during creation:

OutputRenderTarget = NewObject<UTextureRenderTarget2D>(GetWorld());
OutputRenderTarget->InitAutoFormat(256, 256);
OutputRenderTarget->AssetImportData = nullptr;
OutputRenderTarget->UpdateResourceImmediate(true);

As far as I could tell, this didn’t seem to have any negative consequences, but YMMV.

Oh, wow! that’s awesome!
Thanks!
I had given up and gone down the serialize-an-array route. I may have to pick this idea back up now!