Есть структура:
#pragma once
#include "CoreMinimal.h"
#include "FColumnBoard.h"
#include "FRowBoard.generated.h"
USTRUCT(BlueprintType)
struct FRowBoard
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
TArray<FColumnBoard> columns;
};
и класс:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FRowBoard.h"
#include "Board.generated.h"
UCLASS()
class CHESS_API ABoard : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ABoard();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UStaticMeshComponent* board;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
TArray<FRowBoard> rows;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UClass* pawnWhite;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UClass* pawnBlack;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UStaticMesh* cube;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UMaterialInterface* color;
};
У него следующий конструктор:
PrimaryActorTick.bCanEverTick = true;
this->board = this->CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoardStaticMesh"));
this->SetRootComponent(this->board);
const int32 sizeColumn = 118.0f;
FVector boundsColumn = FVector(sizeColumn * 0.02f, sizeColumn * 0.02f, 0.01f);
for (int32 i = 0; i < 8; ++i) {
FRowBoard row;
FVector forwardVector = (FVector::ForwardVector * i - FVector::ForwardVector * 4) * sizeColumn * 2 + FVector::ForwardVector * sizeColumn;
for (int32 j = 0; j < 8; ++j) {
FColumnBoard column;
FVector rightOffset = (FVector::RightVector * j - FVector::RightVector * 4) * sizeColumn * 2 + FVector::RightVector * sizeColumn;
FString name = TEXT("col_");
name.AppendInt(i + 1);
name.AppendInt(j + 1);
auto col = this->CreateDefaultSubobject<UStaticMeshComponent>(FName(name));
col->SetupAttachment(this->board);
col->SetRelativeScale3D(boundsColumn);
col->SetStaticMesh(this->cube);
col->SetMaterial(0, this->color);
col->SetRelativeLocation(rightOffset + forwardVector);
col->SetVisibleFlag(false);
column.column = col;
column.location = rightOffset + forwardVector;
row.columns.Add(column);
}
this->rows.Add(row);
}
До выхода из конструктора в rows 8 структур, в каждой из которых 8 елементов массивов. Но в редакторе и в BeginPlay rows где-то теряет вложеные масивы и остаётся только восемь елементов, в каждом из которых лежит ноль элементов.
Как исправить?