In my loading scene I want to run multiple functions (IO from the disk) and start the app after they are completed.
This is in my loading class. (Note: This is unity 3d and the public variables to get access to other objects is based on Unity best practices).
public Logger MyLogger;
public Parser MyParser;
// ... more
private int coroutineCount = 0;
void Start()
{
MyLogger.LogLastMonth(Callback);
coroutineCount++;
MyParser.ParseFiles(Callback);
coroutineCount++;
}
public void Callback()
{
coroutineCount--;
if (coroutineCount <= 0)
{
SceneManager.LoadScene("GameScene");
}
}
I do something similar in both Logger and Parser (counting coroutines and decrementing when they finish before invoking the callback received). Is there a better way to do this when I need to expand the number of functions I'm calling?
Thanks!