I have some working code for generating my uassets. The only problem is it always creates a copy at the root of the plugin directory, as well as, in the target subdirectory. Anyone have any idea why SavePackage
is doing this?
FString playerController = contentPath + "/PlayerController";
if(platformFile.CreateDirectoryTree(*playerController))
{
FString mountPoint = TEXT("/Dialogue/PlayerController");
FPackageName::RegisterMountPoint(
*mountPoint,
*playerController);
UPackage *package = CreatePackage(nullptr,
` *(mountPoint + "/ThirdpersonCharacter"));
ADialoguesCharacter *newAsset = NewObject<ADialoguesCharacter>(
package, ADialoguesCharacter::StaticClass(),
` TEXT("ThirdpersonCharacter"),
RF_Public | RF_Standalone
);
newAsset->MarkPackageDirty();
// Here is where the duplicate is
UPackage::SavePackage(package, newAsset,
EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
*((playerController + "/ThirdPersonCharacter") +
FPackageName::GetAssetPackageExtension())
);
newAsset->Destroy();
}