# Blueprint Nativization turns TSubclassOf into UClass\* which prevents build

**URL:** <https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363>\
**Category:** Blueprint\
**Tags:** compiling, nativization, unreal-engine, bug-report, question, Blueprint, CPP\
**Created:** [February 27, 2017, 11:41am UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363 "2017-02-27T11:41:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FTC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FTC](https://forums.unrealengine.com/u/FTC)\
**Post date:** [February 27, 2017, 11:41am UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/1 "2017-02-27T11:41:40Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![moookiexl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@moookiexl](https://forums.unrealengine.com/u/moookiexl)\
**Post date:** [February 27, 2017, 5:42pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/2 "2017-02-27T17:42:54Z")

</div>

Can confirm, i’m experiencing exact same bug:

> **[Blueprint nativization fails if there's any c++ code using TSubclassOf](https://forums.unrealengine.com/questions/568437/blueprint-nativization-fails-if-theres-any-c-code.html)**
>
> Calling any C++ method that has TSubclassOf parameter, or attempting to set any TSubclassOf UPROPERTY both cause blueprint nativization to fail. From looking at resulting code it appears that blueprint translates all subclass references to UClass\*,...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [March 9, 2017, 7:15pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/3 "2017-03-09T19:15:40Z")

</div>

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](https://issues.unrealengine.com/issue/UE-42676) to reflect your report.

---

<div class="post-metadata">

**Author:** ![zamy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zamy](https://forums.unrealengine.com/u/zamy)\
**Post date:** [August 13, 2017, 4:20pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/4 "2017-08-13T16:20:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zamy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zamy](https://forums.unrealengine.com/u/zamy)\
**Post date:** [August 13, 2017, 5:14pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/5 "2017-08-13T17:14:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [March 8, 2018, 10:55pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/6 "2018-03-08T22:55:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![moookiexl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@moookiexl](https://forums.unrealengine.com/u/moookiexl)\
**Post date:** [March 8, 2018, 10:59pm UTC](https://forums.unrealengine.com/t/blueprint-nativization-turns-tsubclassof-into-uclass-which-prevents-build/386363/7 "2018-03-08T22:59:39Z")

</div>

The bug has been fixed in 4.17 ( [Unreal Engine Issues and Bug Tracker (UE-44511)](https://issues.unrealengine.com/issue/UE-44511) )
