Hi BioMedKUL
The GameMode may not stay the same throughout. Each time a level loads, the current game mode gets destroyed and a new one is formed even if they are of the same type. It is the exact same for every other object (except the GameInstance).
widget itself also has only one
instance that gets removed and added
to the viewport
This line confuses me a little. If you remove your widget entirely from the viewport, it gets destroyed and reinitialized when it is readded so the constructor will run again which will be required to reset itself and cache any references it needs.
Having the widget store a reference to the GameMode on Construct is the best way to go about this.
I would discourage having the GameMode storing references to widget objects due to that is not how the architecture for a project should be set up (in most cases).
The GameMode class is used to define the rules for the level and the handling of controller objects. In short term, objects like widgets etc are irrelevant to the GameMode. UI should be handled by the HUD or PlayerController classes. Widgets may want to access the GameMode to retrieve certain information but the GameMode shouldn’t be accessing widgets to tell them about the information.
I hope my answer makes sense.
Alex