for (FMyStruct& Item : MyArray)
{
// Here Item can be modified and the element in the MyArray will be updated due to the "&"
//Add only elements that are active to MyArray2
if (Item.IsActive)
{
MyArray2.Add(Item);
}
}
The issue here is that MyArray2 will contains copy of Struct of MyArray, so if I change some struct data in MyArray2, it won’t be reflected in MyArray.
Do you know how to solve this issue?
the only way I found was to create MyArray2 as TArray<FMyStruct*>
Hi! Yep, MyArray2 contains copies of FMyStruct. You can’t store references in the array. So the only solution is to store pointers in the array. For example: