So I have created this Widget for my Barracks that allows the Player to train new Units and also Queue them. The Barrack is then training one Unit at the Time. This works fine.
When I close the UI for the Barrack I remove it from the main HUD. Because of this I need to save the Content of the Recruitment Queue and restore it when the same Barrack is clicked again. This is done in the “RecruitmentQueue” Array.
To show the Queue in the UI I create a Widget “UnitRecruitQueueCard” in the Horizontal Box “RecruitmentQueue1” for each element in the “RecruitmentQueue” Array.
Once the Unit is spawned I remove this Unit from the Array and the Widget.
Also this works. The Problem I’m having is that once the UI with the content is restored that the remaining Units in the Build Queue do get removed from the Array but not from the Horizontal Box.
My guess is that this is caused because the Horizontal Box “RecruitmentQueue1” that is created when the Barrack is clicked again isn’t the same refrence as when the Widget got created the first time.
I tried to save and restore this refrence in the same way as I save the “RecruitmentQueue” Array but then I don’t get the Horizontal Box “RecruitmentQueue1” in the UI at all when the Barrack is clicked again.
Here is a short clip with the Menu open.
And here is a clip what happens when I close and reopen the Menu while Units are being recruited.


