After playing with a packaged project, I noticed that my Settings widget (who calls a GameMode function to fill mouse-related settings from savegame) got a -1 value. This value is returned when GameInstance is null. As far as I know, GameInstance is the first thing that is created by the Engine and it is where my SaveGame-related functions are.
Basically (in pills) MainMenu widget creates a Settings widget which calls GameMode->GetMouseSensitivity, which calls a GameInstance->LoadGame.
This works perfectly fine in the editor as you can see from this log:
1)Creating GameMode
2)Creating MainMenu widget and sub widgets including Settings
3)Settings widget calls GameMode->GetMouseSensitivity, which calls a GameInstance->LoadGame
4)Settings widget applies settings
But this is what happens after playing the executable version:
1)Creating MainMenu widget and sub widgets including Settings
2)Settings widget calls GameMode(which has not been created yet (??)) ->GetMouseSensitivity but fails because GameMode doesn’t exist yet
3)Therefore returns -1
4)GameMode is created
5)GameMode calls CreateNewGame function in GameInstance
So, does that means that the order of creation of widgets, game modes etc. is not consistent between editor and executable versions? What should I do to avoid that?