using c++ struct in blueprint ?

Hi,

this is driving me nuts

how the hell do I use a C++ struct inside one of my blueprint ?

USTRUCT(BlueprintType)
struct FBlenderCsvData : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()
public:
	UPROPERTY(EditAnywhere)
		int Id;
	UPROPERTY(EditAnywhere)
		FString Type;
	UPROPERTY(EditAnywhere)
		FString Name;
...

I cannot break the output node with the c++ structure

how can I use my structure in blueprint

I tried redefining a struct in the editor, and use it, but it gives me errors like
“incompatible output parameter; the data table’s type is not the same as the return type”

any help appreciated

you need to add BlueprintReadWrite to the UPROPERTYs to access them in the Blueprint graph

[EDIT] Also, I don’t think blueprints support the default int, you’ll probably have to use int32.

1 Like

you mean, add BlueprintReadWrite to all properties in the struct or the one declared in the main class ?

cos I already do that

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ATop)
		FBlenderCsvDataStruct CsvDataStructure;

u need to add BlueprintReadWrite on each of UPROPERTY of the struct member

USTRUCT(BlueprintType)
struct FBlenderCsvData : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		int Id;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FString Type;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		FString Name;
}
USTRUCT(BlueprintType)
struct FTileIdentity
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        FIntVector TileID;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        FVector VecLoc;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        AActor* Store;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        int32 Col;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        int32 Row;
};

I use this in a class which extends Blueprint Function Library and do so with zero problems. Be forewarned though, avoid using hot loading or “live coding” when you create your struct or else you’ll be in a world of pain the next time you open the editor (you can do it, but you must compile your project in your IDE after closing the editor)…

ok but that means I would have to redefine another struct with the exact same fields

Why?

ok indeed I finaly made it word
oddly enoug, the Id field must not be declared otherwise the import does not work
well as I dont need that field anyway

thanks everyone !

the id field doesn’t work because blueprint doesn’t support int. use int32 instead.

I did, same issue

now I have a bigger problem, vector:rotator dont get converted from the CSV

ok I missed X= … in my csv

Manually fill 1 row of the data table with data, right click the Data Table asset in the Content Browser and click Export as CSV. You can then use the exported CSV as a template.

The rotator might need to be defined like this in CSV : (Pitch=0.000000,Yaw=0.000000,Roll=0.000000)

great idea
thanks

1 Like