With some days of reworking the whole Main Menu functionality from the ground up, I think I finally got it to work.
The issue was that I didn't structure my stuff as I should, namely I had logic on multiple objects, data on multiple objects and everything was dependent on everything. Without structure, I basically wrote logic to any script that was open, needless to say it was kind of dumb. But the main reason this crashed my game is that even if my objects are by default turned on (active), somehow after loading the main menu they remained turned off.
Now I have a persistent
GameData with a script on it named
Persistence. It uses
DontDestroyOnLoad and is a singleton, this is responsible for actually calling the initializers on the gameobjects.
At the first - as this main menu is sort of a small scene - I get all scene gameobjects into a collection - and only query them later on using LINQ.
Also, I have no
Start only any gameobjects in the scene.
Now, I also made an
abstract class named
InitializeMe that looks like so:
public abstract class InitializeMe : MonoBehaviour
public int orderNumber;
public abstract void INIT(Persistence pers);
Where the ordernumber is used in a LINQ query when getting the menu's gameobjects who has an
InitializeMe on them.
Then I have descendants of this
InitializeMe that obviously implement that abstract class and tell exactly what to do in their case. As They get access to
Persistence easily (they are called from that very class) and this
Persistence holds most of the data that is ever needed, initialization is made very easy in an order easy to predict and control.
With this and the save/load and check file integrity coming first, loading a scene was rather quick and stable.