I found this code about UPanel
int32 Children = GetChildrenCount();
for ( int32 ChildIndex = 0; ChildIndex < Children; ChildIndex++ )
{
RemoveChildAt(0); // -?? I Don’t know this code.
}
why did you use the zero index?
Let me know plz.
I found this code about UPanel
int32 Children = GetChildrenCount();
for ( int32 ChildIndex = 0; ChildIndex < Children; ChildIndex++ )
{
RemoveChildAt(0); // -?? I Don’t know this code.
}
why did you use the zero index?
Let me know plz.
The index 0 is used because arrays in Unreal are actually lists and not regular c++ arrays. So whenever you remove an element from an array at a certain index (this case 0) all the items that follow are moved to take up the removed space.
For instance, lets say you have an array of child widgets (widget0, widget1, widget2) - array size 3 -, so, if you remove index 0 you are left with (widget1, widget2) - array size2 -, widget1 becomes index 0 and widget2 becomes index 1.
If you removed ChildIndex instead of 0 you would remove only half of the elements before getting an access violation exception.
Hope this helps. Make it a great day!
Thank you for answer. I knew for sure.