虚幻引擎 C++ 数据资产类问题

P. *_*Jan 2 c++ unreal-engine4

因此,我尝试创建一个自定义数据资产以在虚幻引擎中使用。我对此非常陌生,我主要关注艺术,所以尽管我对 OOP 有一个大致的了解,但 C++ 远不是我的强项。无论如何,我的课程如下所示:

USTRUCT()
struct FTrainFormations {

    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere)
    FString TrainEntry;

    UPROPERTY(EditAnywhere)
    bool Flipped;

    UPROPERTY(EditAnywhere)
    bool CargoLoaded;

    UPROPERTY(EditAnywhere)
    bool AllowSubstitution;

};

UCLASS(BluePrintType)
class TS2NEW_API UTrainFormation : public UDataAsset
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Train")
    TArray<FTrainFormations> Formation;

    UPROPERTY(EditAnywhere, Category = "Train", DisplayName = "Train Numbering Overrides")
    TArray<int> TrainNumberingOverrides;

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle Substitution")
    float BlockTrainProbability;

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rail Vehicle Information")
    int CommonnessWeighting;

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rail Vehicle Information")
    bool IsSubstitutableUnit;

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rail Vehicle Information")
    bool IsDrivable;

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Browse Information", DisplayName = "Friendly Name")
    FString NameProperty;
};
Run Code Online (Sandbox Code Playgroud)

这有效地创建了一个数据类:

数据资产

我的问题是 - 如何将主数组元素从“4 成员”更改为第一个字段的值?这样,当我稍后查看数组时,我可以看到数组内部的内容,而无需扩展它。我到处都找过了,但找不到任何关于此的信息,但我可能又在寻找错误的东西。

P. *_*Jan 5

已解决:实际上非常简单,只是很难找到答案,因为似乎没有人知道。

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Train", meta = (TitleProperty = TrainEntry))
TArray<FTrainFormations> Formation;
Run Code Online (Sandbox Code Playgroud)

本质上,您必须在数组的 UPROPERTY 上使用元数据说明符“TitleProperty”,并且可以设置静态标题或将其指向将覆盖“# Members”的变量。根据上面的问题,此示例将其指定为 FString TrainEntry的值。

例子