A7E7
(A7E7)
1
Hey guys,
I’m simply trying to name a component with a variable.
for (int i = 0; i < 5; ++i)
{
UStaticMeshComponent* tmp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh" + i));
...
}
// or TEXT("Mesh%d", i)
I know this is somehow basic, but I really can’t figure it out. Does anyone know a way to do this?
Thanks in advance!
PasteDog
(PasteDog)
2
Hey A7E7,
You could try something like:
CreateDefaultSubobject<UStaticMesh>(*FString("Name" + FString::FromInt(i)));
Also take a look at this link for more information:
Hope this helps
Elias
A7E7
(A7E7)
3
Thanks a lot! I actually tried it like this but without the *
PasteDog
(PasteDog)
4
Yea it is because you need to convert the FString to FName.
Np!