Download

Is there an import cache?

I’ve written a custom import class. After importing a variety of files, quitting and reloading, every time I import, every single element I’ve ever imported with it EVER appears under “Script Content”. It’s getting annoying, to say the least. Somehow this is persisting through the Derived Data Cache being removed.

Any ideas? Is there a location or a file I could go and delete? Why are the items not leaving this cache when they’re done, wherever it is?

My gut feeling is that it’s ending up in Script Content because I’m not saving it properly (but I can still use it in the editor). Deleting things from there doesn’t really delete them though, so things are coming back. My log trace suggests the importer is only finding the files I intend to import, not all of the extras.

So this is also a question about the Script Content folder in the content browser and how to get out of it. This is the code I use to save a generated texture to the content browser:


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;
}