Figured out the problem and a work around.
The UnrealHeaderTool code generator doesn’t appear to take into account the new UncookedOnly type when setting package flags to determine what should be included in nativization.
To get around this you can manually set the package flags. PKG_EditorOnly or PKG_Developer should work. You can see where they’re normally set under CodeGenerator.cpp
I did this during module startup and it seemed to work without issue.
void FYourEditorModule::StartupModule()
{
const FString LongName = FPackageName::ConvertToLongScriptPackageName(TEXT("YourEditorModuleName"));
if (UPackage* Package = Cast<UPackage>(StaticFindObjectFast(UPackage::StaticClass(), nullptr, *LongName, false, false)))
{
Package->SetPackageFlags(PKG_EditorOnly);
}
...
If you want to see where these flags are normally set you can find them under \Engine\Source\Programs\UnrealHeaderTool\Private\CodeGenerator.cpp
Package->SetPackageFlags(PKG_ContainsScript | PKG_Compiling);
Package->ClearPackageFlags(PKG_ClientOptional | PKG_ServerSideOnly);
if (Module.ModuleType == EBuildModuleType::GameEditor || Module.ModuleType == EBuildModuleType::EngineEditor)
{
Package->SetPackageFlags(PKG_EditorOnly);
}
if (Module.ModuleType == EBuildModuleType::GameDeveloper || Module.ModuleType == EBuildModuleType::EngineDeveloper)
{
Package->SetPackageFlags(Package->GetPackageFlags() | PKG_Developer);
}
These are then read in \Engine\Source\Developer\BlueprintNativeCodeGen\Private\BlueprintNativeCodeGenManifest.cpp to determine if the module should be included in the module references of nativized assets.
// we want only native packages, ones that are not editor-only
if ((DependentPackage->HasAnyPackageFlags(PKG_CompiledIn)) && !DependentPackage->HasAnyPackageFlags(PKG_EditorOnly | PKG_Developer) && !DependentPackage->IsLoadedByEditorPropertiesOnly())
{
DependenciesOut.AddUnique(DependentPackage);// PkgImport.ObjectName.ToString());
}