One of my UObject classes has an array
UPROPERTY()
TArray<FGridNode> nodes;
of the simple struct
USTRUCT()
struct FGridNode {
GENERATED_BODY()
UPROPERTY()
FVector pos;
UPROPERTY()
bool blocked;
UPROPERTY()
int flag;
UPROPERTY()
int neighbours[8];
};
In OnConstruction
the array is filled with one million elements, nodes.SetNum(1e6);
After hitting Play in Unreal Editor, an instance (the CDO I suppose) of this class gets duplicated and its member nodes
gets copied.
This takes very long, about 7s. However, a direct copy of an TArray of this length takes only 30ms.
Where does this difference come from? How can I speed up the starting phase of the game?