Blueprint Nativization turns TSubclassOf into UClass* which prevents build

Hello,

After a customer reported a problem with packaging my plugin using Blueprint Nativization I tracked down a bug. I use a couple of BlueprintNativeEvent UFUNCTIONs, but the generated nativization code contains errors. I picked an example method in one of my classes. This is how it is declared:

UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "AdvKit")
bool CreateTransitionBetween(TSubclassOf<AAdvKitCharacter> ForCharacterClass, AAdvKitZone* SourceZone, AAdvKitZone* TargetZone);
virtual bool CreateTransitionBetween_Implementation(TSubclassOf<AAdvKitCharacter> ForCharacterClass, AAdvKitZone* SourceZone, AAdvKitZone* TargetZone);

The signature inside the generated blueprint c++ code looks like this however:

virtual void CreateTransitionsFor_Implementation(UClass* bpp__ForCharacterClass__pf, AAdvKitZone* bpp__ForZone__pf) override;

The first argument’s type has been changed from TSubclassOf to UClass* resulting in the compiler throwing this error:

UATHelper: Packaging (Windows
(64-bit)): UnrealBuildTool:
C:\Project\Intermediate\WindowsNoEditor\NativizedAssets\Source\NativizedAssets\Public/BP_LadderStepBuilder__pf964772836.h(20): error C3668:
‘UBP_LadderStepBuilder_C__pf964772836::CreateTransitionsFor_Implementation’:
method with override specifier
‘override’ did not override any base
class methods

This happens for every method using TSubclassOf as an argument. I hotfixed it by introducing a virtual method in the base class that matches the signature and calls the correct method:

bool UAdvKitTransitionBuilderModule::CreateTransitionBetween_Implementation(UClass* ForCharacterClass, AAdvKitZone* SourceZone, AAdvKitZone* TargetZone)
{
	if (!ForCharacterClass->IsChildOf(AAdvKitCharacter::StaticClass()))
	{
		return false;
	}

	TSubclassOf<AAdvKitCharacter> Class = ForCharacterClass;
	return CreateTransitionBetween_Implementation(Class, SourceZone, TargetZone);
}

However that is no permanent fix and it also adds unecessary overhead to every method. I don’t want to change my code to use UClass* because if a TSubclassOf is exposed in Blueprint the editor automatically filters the class list to show only applicable ones.

Kind Regards,

Can confirm, i’m experiencing exact same bug:

Hi ,

This does appear to be the same issue that was reported by moookiexl in the linked post. I have added some additional information to UE-42676 to reflect your report.

I’m sorry to inform you that even if the tickes is signed as Fixed for 4.16,
on 4.16.2 i’m still having this issue

And i’ll add in another issue:

UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "ImperoResources")
	bool CanBeFarmedBy(const TScriptInterface<IEntityInterface>& Entity) const;
	bool CanBeFarmedBy_Implementation(const TScriptInterface<IEntityInterface>& Entity) const { return true; };

(as you can see, a input parameter)

gets nativized as:

virtual bool  CanBeFarmedBy_Implementation(/*out*/ TScriptInterface<IEntityInterface> const& bpp__Entity__pf__const) const override;

So an out parameter, giving an error.

The bug has been fixed in 4.17 ( Unreal Engine Issues and Bug Tracker (UE-44511) )

Hi zamy,

Sorry for not responding sooner. I am no longer able to reproduce the issue that was reported in UE-42676. Are you still running into it? If so, would you be able to provide a small test project where the issue is still occurring?