how to use SetMaterial () to add multiple materials

hello I want to add several materials from the function SetMaterial()

struct FConstructorStatics
{
	ConstructorHelpers::FObjectFinderOptional<UMaterial> MaterialNumbers;
	FConstructorStatics()
		: MaterialNumbers(TEXT("/Game/Textures/dice_1_Mat.dice_1_Mat"))
	{
	}
};
static FConstructorStatics ConstructorStatics;

Box = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Box"));
Box->SetMaterial(0, ConstructorStatics.MaterialNumbers.Get());

What I want is to add another material, for example, to MaterialNumbers

Box->SetMaterial(1, ConstructorStatics.MaterialNumbers.Get());

Do you already have multiple materials created in the /Game/Textures folder and you just want to get them assigned to your Box? Since you hard-coded only a single reference to dice_1_mat the other material won’t ever be found.

Something like this?

for(int i = 0; i < 100; i++)
{
    ConstructorHelpers::FObjectFinderOptional<UMaterial> MaterialNumber(*FString::Printf(TEXT("/Game/Textures/dice_%i_Mat.dice_%i_Mat"), i+1, i+1));
    if(!MaterialNumber.Succeeded())
        break;

    Box->SetMaterial(i, MaterialNumber.Get());
}

I used 100 as the maximum number of possible materials. This could be any arbitrary number or it could be set as a parameter of the CDO.