Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnrealEngine4 - Restricting DataTable pointer to only use certain row structure

So i have these two structs:

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

public:

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    int32 LocationX;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    int32 LocationY;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    TSubclassOf<ATile> TileType;
};

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

public:

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    UDataTable* MapTable;
};

I want to allow blueprint data table created with row structure FLevelStruct to only be able to use data table created with FLevelMapStruct row structure in field MapTable.

Can someone point me in the right direction about how could i do this?

Edit: the MapTable will need to be able to point to blueprint data table

like image 478
Amakazor Avatar asked Apr 25 '26 17:04

Amakazor


2 Answers

For custom Class with Unreal 5.1, I use this :

UPROPERTY(meta = (RequiredAssetDataTags = "RowStructure=/Script/MyProject.MyData"))
UDataTable* database = nullptr;

UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (RowType = "/Script/MyProject.MyData"))
FDataTableRowHandle rowIntoDatabase;

UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (RowType = "/Script/MyProject.MyData"))
TArray<FDataTableRowHandle> someRowIntoDatabase;

It's same comment: Note that the F isn't included in the name of the RowStructure, so MyData rather than FMyData

It's work inside USTRUCT, I create my DataTable with it.

like image 83
Rominitch Avatar answered Apr 27 '26 08:04

Rominitch


I have just hit this exact issue myself and I believe I have the answer (works for me at least with UE 4.26). Have seen a few posts asking with no answer so figured I should share my solution.

In the UPROPERTY macro add meta=(RequiredAssetDataTags = "RowStructure=*YoureRowTypeHere*")

So in your example you would have

UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(RequiredAssetDataTags = "RowStructure=LevelMapStruct"))
UDataTable* MapTable;

Note that the F isn't included in the name of the RowStructure, so LevelMapStruct rather than FLevelMapStruct

In editor now, your property should only list the tables that use that type.

like image 28
Graeme Avatar answered Apr 27 '26 08:04

Graeme



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!