Add Child on VBox Not working as expected.

I’m trying to make a scoreboard for a multiplayer game. I have created two UMG Widgets to handle this. One is simply a canvas with a VBox at the top left, and the other is a plain widget with a text field.

I’m using On Event Tick on the widget with the vbox on it (The VBox is called ‘VBox Scores’), and it updates the list of players from the gamestate and then iterates over their playerstates creating a new text field widget for each one with the player name and his score. It then uses an ‘Add Child’ node with the VBox as its target to add the new Text widget to it.

I expect that with a PlayerArray of length 2, I would see two player scores. However I consistently only see one on both clients and the server, and it’s always the same player name (currently incrementing numbers in Play In Editor).

This is the blueprint which iterates over the players (which are set elsewhere, but I have a debug ensuring there are the correct number present). This is what I see on the client.

27091-uiclientoutput.png

The 2 on Client -2 is the length of that array, and I’d expect to see two text areas instead of the single ‘332: 0’. I’ve also confirmed with breakpoints and another print string that the AddChild is being called twice.

The Add to Viewport is also on the PlayerController’s Begin Play Event.

I would expect that Add Child would create another text widget underneath any previous ones in the VBox, but that VBox only seems to contain one entry. Even after Add Child is called twice.

So I figured it out, and I feel really sheepish. The ‘size to content’ was unchecked and only the first score was visible.

Once I checked that box, the VBox would expand to show additional scores.