private void Start()
{
_dimensions = Dimensions.instance;
// TODO: Use this only on first game-run?
ConfigureCanvas();
ResetQualitySettingsToDefault();
GetBestFontSizes();
RunQualityInspector();
}
Will those method calls run absolutely one after another? or they might run together at the same time?
I want to to run each function of the above 4 functions only after the previous one has finished, because it depends on the values that the previous functions produces.
Yes. The only way that that wouldn’t happen would be if you were running each function in a separate thread, and you have to go way out of your way to do that.
(Or starting each one with a StartCoroutine call, though even in that case you can specifically choose where you want code in each function to be able to stop and allow other code to run by where you place your “yield return” statements.)
No, you’d have to explicitly make it happen, in code. For example:
private void Start()
{
_dimensions = Dimensions.instance;
// TODO: Use this only on first game-run?
Thread t1 = new Thread( () => ConfigureCanvas());
t1.Start();
Thread t2 = new Thread( () => ResetQualitySettingsToDefault());
t2.Start();
Thread t3 = new Thread( () => GetBestFontSizes());
t3.Start();
Thread t4 = new Thread( () => RunQualityInspector());
t4.Start();
}
So yeah, you have to try really hard to make them actually run concurrently.
If these functions go into code you don’t control there’s a tiny chance that some code inside there is kicking off something in a thread but not likely - most Unity code just doesn’t do that.
If the reason for asking this question is a particular bug you’re trying to fix, maybe be more specific about the actual bug?
No bug, i was just curious about the original question:
if i called multiple functions after each other; will a function wait the previous one to return for it to start?
and the answer was YES. unless i was making threads like you showed me, and i’m not doing that. So i don’t have to worry about them being run simultaneously. Right?
You don’t have to worry about them running simultaneously. Unless you go out of your way to do otherwise (as already stated), all of your MonoBehaviour code runs on the “main thread”. An individual thread runs functions one at a time in order, and the main thread is no different.