Hmm. The only problem with that is that I’m only importing OBJ files so there’s no texture information to speak of, just loosely associated image files that I have a separate mapping for applying to the mesh. Because of this I need to import everything and then walk my other structure to create and assign all of the materials.
How do you enable the import UI anyway? Also, what is “context” during these calls?
Ultimately I have to kick off a texture import somehow. I guess I’ve actually looked at all of this before and just need to check my notes.
This is what I have right now:
UE_LOG(LogTemp, Warning, TEXT("Importing texture: %s"), *Filename);
const FString Filepath = FString("C:\\Temp\\Import\\assets\\") + Filename;
TextureFactory->CurrentFilename = Filepath;
const uint8 * Buffer = 0;
bool bAndOutOperationCancelled = false;
Filename.ReplaceInline(TEXT(" "), TEXT(""));
FString PackageName = FString("/Game/ImportedAssets/") + *Filename;
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackageName, FPackageName::GetAssetPackageExtension());
UPackage * Package = NewObject<UPackage>(UPackage::StaticClass(), FName(*PackageName), RF_Standalone | RF_Public);
Package->SetFlags(RF_Standalone | RF_Public);*/
UTexture2D * Texture = (UTexture2D *)UFactory::StaticImportObject(UTexture2D::StaticClass(), Package, FName(*Filename), RF_Standalone | RF_Public, *Filepath);
Package->SavePackage(Package, Texture, RF_Standalone | RF_Public, *Filename, GWarn);
So the path is “/Game/ImportedAssets/”, but instead I get this:
LogTemp:Warning: Importing texture: Farmhouse Texture Bump Map .jpg
LogFactory: FactoryCreateBinary: Texture2D with TextureFactory (0 0 C:\Temp\Import\assets\Farmhouse Texture Bump Map .jpg)
LogTexture:Display: Building textures: FarmhouseTextureBumpMap.jpg (AutoDXT)
LogSavePackage: Moving '../../../../../../UnrealEngine/Projects/UE4Importer/Saved/FarmhouseTextureBumpMap65B2A84C4C48C8DBD2D1D095631A1E97.tmp' to 'FarmhouseTextureBumpMap.jpg'
LogSavePackage: Total save time: 75.882137ms
LogSavePackage:Warning: Finished SavePackage FarmhouseTextureBumpMap.jpg
And this appears in the content browser:
Those images aren’t openable:
LogUObjectGlobals:Warning: Failed to find object 'Object /Script/CoreUObject.Package./Game/BakedAssets/FarmhouseTextureBumpMap.jpg.FarmhouseTextureBumpMap.FarmhouseTextureBumpMap.jpg'
The naming structure seems odd and it’s definitely not where I specified it should be saved. So it looks like it’s importing the texture fine but then it’s lost to the void.