Identical code will compile in a code-based project but not when I add it to a BP-based project

All other steps are identical, I add the code via the editor. It will compile correctly if I’m using the Code-based first person template, but if I add the code to the BP-based First Person template in the same manor, it triggers a breakpoint when debugging and the project will not load in the EU4 Editor correctly.

In both cases, I’m using the EU4 Editor to add the new class to the project. I’m using 4.3.0 and Visual Studio 2013

The code is the same code from the “Data Driven Gameplay” example documentation:

#pragma once

#include "GameFramework/Actor.h"
#include "CraftableItemsStruct.generated.h"

USTRUCT(BlueprintType)
struct FLevelUpData : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()

public:

	FLevelUpData()
		: XPtoLvl(0)
		, XP(0)
	{}

	/** The 'Name' column is the same as the XP Level */

	/** XP to get to the given level from the previous level */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)
		int32 XPtoLvl;

	/** This was the old property name (represented total XP) */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)
		int32 XP;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)
		TAssetPtr<UTexture> Asset;
};

Hi Hyperloop,

What class are you selecting when you add code to your project to include the struct? Also, are you using the binary version of the Editor through the Launcher, or did you compile the Editor from source code?

Hi ,

I’m using the binary version. I used no parent class to add the code in either case, I just completely replaced the default code in the created .h file with the code sample from above. Admittedly, I’m very new at this so it’s likely user error on my part although it works perfectly in the code-based template so I’m not certain.

Hi Hyperloop,

Thank you for the clarification. I was able to reproduce the issue that you described, and have submitted a report about this issue to the development team for further investigation. We apologize for any inconvenience this may cause, and hope to have it resolved soon.

Thanks,

No problem! Thanks for the reply - using the code based template will work just dandy for now.

Hi Hyperloop

All native-code entities, that use UE4 meta data system (so all USTRUCT, UENUM, etc… everything dependent on auto-generated code), MUST be declared in a header file with a UClass declaration. That’s the way how UHT (unreal header tool) and auto-generated code works. It’s rather a strong assumption.

So even if a UClass isn’t used, it should remain as a dummy (the .cpp file with constructor should remain too). And all structures can be declared above it.
Even if an UStructs declared in a header, without UClass, works fine at the moment (like the one from project using the code based template). It is error-prone, because the UHT is constantly improved/changed, and in a future version it can cause an error.

Cheers,
M