I’ve been programming a tool for generating static cubemap textures in editor and I’ve almost got it working. My only remaining problem is that I can’t get the created .uasset files to show up in the content browser.
The code does as follows:
First it gets the path to the level folder and then creates a new folder (package?) inside it that is the name of the level and _TOD suffix. After that I call the ConstructTextureCube function on the capture component which should(?) construct a static texture cube with mip maps and what not. Then the cube and the package it’s in is marked dirty and added to an array for pending save. Finally I call PromptForCheckoutAndSave which correctly opens the prompt and also lists all the created texturecubes. Saving them makes the files appear on my HDD in the correct path, but they don’t show up in the content browser. The _TOD folder doesn’t show up either unless I restart the editor. Then it shows up. But the individual cube uassets don’t show up even though they are in that folder in explorer.
Below is a print of the full path of a cube.
LogTemp: cube full path:TextureCube /Game/Maps/Map1/Desert_TOD/sky_cubemap_azimuth_0_altitude_-20./Game/Maps/Map1/Desert_TOD/sky_cubemap_azimuth_0_altitude_-20
TArray<UPackage*> PackagesToSave;
const FString todAssetPath = this->GetOutermost()->GetName() + TEXT("_TOD/");
FString assetPath = FString::Printf(TEXT("%ssky_cubemap_azimuth_%i_altitude_%i"), *todAssetPath, azimuth, elevation);
UPackage* package = CreatePackage(NULL, *assetPath);
if (package)
{
const FString name = FString::Printf(TEXT("sky_cubemap_azimuth_%i_altitude_%i"), azimuth, elevation);
UTextureCube* cube = captureComponent->TextureTarget->ConstructTextureCube(package, assetPath, EObjectFlags::RF_Standalone);
if (cube)
{
cube->MarkPackageDirty();
cube->GetOuter()->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(cube);
UE_LOG(LogTemp, Log, TEXT("cube full path:%s"), *(cube->GetFullName()));
PackagesToSave.Add(package);
}
}
bool bCheckDirty = true;
bool bPromptToSave = true;
FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirty, bPromptToSave);
So my question is, how can I do what I want: Save the texture cubes onto HDD as an asset so that they show up in the content browser.