Hello everybody there is a node in unreal engine blueprint :
how can i convert a array into struct in c++ for adding in a TMap?
I specifically want to do this in c++
Hello everybody there is a node in unreal engine blueprint :
how can i convert a array into struct in c++ for adding in a TMap?
I specifically want to do this in c++
Hi @Kaan_Altay
“conver array into struct …” I think this would be more accurate:
I have made a little example with Skill Structs that are saved inside of 2 TArrays and these are stored inside a TMap.
struct Skill
{
FString Name;
int Level;
};
void ULibTools::test1(int i)
{
UE_LOG(LogClass, Log, TEXT("test1-------------------"));
TArray<Skill> SkillArray;
Skill s1 = Skill();
s1.Name = TEXT("Trunk");
s1.Level = 2;
SkillArray.Add(s1);
Skill s2 = Skill();
s2.Name = TEXT("Tank");
s2.Level = 3;
SkillArray.Add(s2);
TMap<FString, TArray<Skill>> Root;
Root.Add("Driving", SkillArray);
TArray<Skill> SkillArray2;
Skill s3 = Skill();
s3.Name = TEXT("Eggs Fried");
s3.Level = 3;
SkillArray2.Add(s3);
Skill s4 = Skill();
s4.Name = TEXT("Pasta");
s4.Level = 1;
SkillArray2.Add(s4);
Root.Add("Cooking", SkillArray2);
for (auto& Category: Root)
{
UE_LOG(LogClass, Log, TEXT("Category: %s"), *Category.Key);
for(auto& Skill: Category.Value){
UE_LOG(LogClass, Log, TEXT(" %s, %i"), *Skill.Name, Skill.Level);
}
}
}
LogClass: Category: Driving
LogClass: Trunk, 2
LogClass: Tank, 3
LogClass: Category: Cooking
LogClass: Eggs Fried, 3
LogClass: Pasta, 1
would be this what you want? your Skills are already struct or anything else?
I don’t think that is what i’m looking for. Thanks anyway.