What's the right way to set a package path in the content browser?

I’ve been trying to get my imported objects to go to the right place for a while without much success. Right now, everything is going into a folder named “Script Content” (Internally it’s called /Script) and not into a path I specify or even where the user specifies the imported files should go. But I also have some questions about packages.

What is a package? My understanding of it right now is that it’s an “Outer” and can give the editor hints about where an asset is located. Can I have more than one asset per package? Do you see packages in the content browser, or just assets?

Anyway, this mess is how I’m trying to move them to the right place right now:

FString PackageName = FString("/Game/BakedAssets"); // +*Filename;UPackage * Package = NewObject<UPackage>(UPackage::StaticClass(), FName(*PackageName), RF_Standalone | RF_Public);
Package->SetFolderName(TEXT("/Game/BakedAssets"));
StaticMesh = (UStaticMesh *)MeshFactory->FactoryCreateBinary(UStaticMesh::StaticClass(), Package, FName(*Filename), RF_Standalone | RF_Public, nullptr, TEXT("obj"), Buffer, 0, GWarn, bAndOutOperationCancelled);

How’s that supposed to look?

This is causing me peripheral problems and stopping me from progressing on my project. I’ve moved on to some tidier saving methods that feel more like the right way to do it, but the issue still remains. Does anyone know what the answer to this is?

This is my new saving method:

UTexture * UNyTexture::SaveToPackage(Thing::ApiRenderImage Image, FName AssetName)
{
	FString Filename = AssetName.ToString();
	UThingImportFactory::CleanFilename(Filename);
	// Filename = Filename + ".jpg";
	FString PackageName = TEXT("/Game/Thing/BakedAssets/") + Filename;
	UE_LOG(LogTemp, Warning, TEXT("[Thing] Saving texture: %s %s"), *PackageName, *Filename);
	UPackage * Package = NewObject<UPackage>(UPackage::StaticClass(), FName(*PackageName), RF_Standalone | RF_Public);

	/// option 1 works but no mipmaps ///////////////////////////////////////////////////////////

	UTexture2D * NewAsset = NewObject<UTexture2D>(Package, FName(*Filename), RF_Public | RF_Standalone, Texture, true);
	NewAsset->PlatformData = Texture->PlatformData;
	NewAsset->CreateResource();
	NewAsset->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
	NewAsset->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
	// NewAsset->ForceRebuildPlatformData();

	bool Success = GEditor->SavePackage(Package, NewAsset, EObjectFlags::RF_Standalone | EObjectFlags::RF_Public, *PackageName, GWarn, nullptr, true, true, NULL);
	// bool success = UPackage::SavePackage(Package, NewAsset, RF_Public | RF_Standalone, *PackageName, GError, nullptr, true, true, SAVE_NoError);

	UE_LOG(LogTemp, Warning, TEXT("[Thing] Saving %s %s"), *Filename, Success ? TEXT("successful") : TEXT("failed"));

	if (Success) {
		FAssetRegistryModule::AssetCreated(NewAsset);
		NewAsset->MarkPackageDirty();
		Package->SetDirtyFlag(true);
		NewAsset->PostEditChange();
		NewAsset->AddToRoot();
		NewAsset->UpdateResource();
	}

	return NewAsset;
}

I’m running into a similar problem and I was wondering if you’ve found a solution?

Thanks