Hello guys, hope this will be helpful
Bug description
In my project i tried for the first time the blueprint nativization procedure, and it failed strangely. Digging it, i found out that it was generating the wrong includes for the blueprints.
In fact, it was skipping a parent include for some classes, for example if i had:
- C++ class named A
- BlueprintClass named B, derived from A
- BlueprintClass named C, derived from B
int the C class header it was correctly extending B, but it was including A directly, resulting in a compiling failure (unknown class B).
I had an hard time reproducing it on a fresh project, below you can find the steps.
Itâs kinda hard to reproduce it, but this way it fails most of the times.
How to reproduce
Note: Since testing it requires packaging, i suggest to disable âFull rebuildâ: i tested with it too, the result is the same.
Note 2: This steps list will show a setup for a working project, then will show how to mess it up, and how to workaround it.
Tested on 4.15.1-0
Initial setup to a working project:
- Create a new âC++ Basic Codeâ project, name it âNativeTestingâ: Desktop, maximum quality and no starter content
- Build the newly created project in VS
- Open the editor
- Create a new C++ class, based on StaticMeshActor, and call it âMyStaticMeshActorâ.
- The following code will be generated, weâll leave it as it is:
MyStaticMeshActor.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Engine/StaticMeshActor.h"
#include "MyStaticMeshActor.generated.h"
/**
*
*/
UCLASS()
class NATIVETEST_API AMyStaticMeshActor : public AStaticMeshActor
{
GENERATED_BODY()
};
MyStaticMeshActor.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "NativeTest.h"
#include "MyStaticMeshActor.h"
- Close the editor and recompile
- Now return to editor, and create a new blueprint class, with âMyStaticMeshActorâ as parent, and call it âMyBaseâ. Open it, save, close.
- Create a new blueprint class, with âMyBaseâ as parent, and call it âSecondBPâ. Open it.
- Add a cube component, save and close.
- Put it in the level, and save it with name âMyLevelâ
- Open Project Settings, and go to Packaging section
- Set BuildConfiguration to Development, uncheck âFull Rebuildâ, and under blueprints set Nativization Method to âInclusiveâ
- Package the project for windows 64: it will work successfully.
Create the problem:
-
Open Project Settings, and go to Packaging section
-
Under blueprints set Nativization Method to âExclusiveâ
-
Open âSecondBPâ, go to class settings and enable âNativizeâ
-
Try to package again.
-
it should fail with errors like these:
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: U:\Unreal Projects\NativeTesting\Intermediate\WindowsNoEditor\NativizedAssets\Source\NativizedAssets\Public\SecondBP__pf1010915279.h(8): error C2504: âAMyBase_C__pf1010915279â: base class undefined
UATHelper: Packaging (Windows (64-bit)): UnrealBuildTool: U:\Unreal Projects\NativeTesting\Intermediate\WindowsNoEditor\NativizedAssets\Source\NativizedAssets\Public\SecondBP__pf1010915279.h(10): error C3646: âSuperâ: unknown override specifier
In fact, looking at the generated code, in Intermediate/WindowsNoEditor/NativizedAssets/Source/Public/SecondBP__****.h, we have:
#include "Blueprint/BlueprintSupport.h"
#include "NativeTesting/MyStaticMeshActor.h"
class UStaticMeshComponent;
#include "SecondBP__pf1010915279.generated.h"
UCLASS(config=Engine, Blueprintable, BlueprintType, meta=(ReplaceConverted="/Game/SecondBP.SecondBP_C", OverrideNativeName="SecondBP_C"))
class ASecondBP_C__pf1010915279 : public AMyBase_C__pf1010915279
{
[âŚ]
Notice how itâs including MyStaticMeshActor.h instead of MyBase_C__pf1010915279.h
Workaround:
- Open the blueprint âMyBaseâ
- Connect something to âBeginPlayâ, like a âPrint Stringâ node, save and close (this will make it a ânormal blueprintâ, not a data-only).
- Try to package again, it will work.
Current Behaviour
On exclusive nativization, seems like it fails to generate the correct includes if the parent is a data-only blueprint.
In fact, in the SecondBP_****.h it places:
#include "NativeTesting/MyStaticMeshActor.h"
instead of:
#include "MyBase__pf1010915279.h"
As already stated, it seems directly related to data-only blueprint, but it doesnât happen on an inclusive nativization.
Expected behaviour
It should always generate the correct include (with the right parent class).
Conclusions
I had an hard time tackling this, it seemed pretty randomic, and i lost a lot of time due to the numerous packaging launches.
I noticed that sometimes it still work, but trying around i can always make it fail in the same way (this is the simplest i found).
I hope this can help you, and maybe others that had issues like me, with the workaround.
Let me know if you need more infos
Simone Daminato
[edit1] : fixed some typos.