Start / Awake and Initialization Issues

I’ve done a lot of searching already on this topic, but it is something that I am greatly confused about.

I have a number of scripts that need to refer to each other in my codebase. Ideally, I’d like some way of ordering the execution of scripts, but this is impossible in Unity.

According to many posts on this forum, Awake() is called in all scripts and then once that is done, Start() is called in each of the scripts. However, this just does not seem to be the case, at least not when running on an iOS device. I have a class called SceneManager which I use to manage many of the other scripts in my codebase. I am therefore initializing only local variables in it’s Awake() method, and then working on other scripts during it’s Start() method. However, when debugging to console on an iOS device, Start() is called after Awake() for this script, but before Awake() is called on other scripts I have in my scene.

What is the definitive initialization order with scripts, and how is one meant to go about initializing scripts that require other objects / classes to be initialized first?

Ah it seems like Awake() is called for every script, and then Start() is called after all Awake() calls have been made.

However, I uncovered a very strange error which was causing a lot of problems. In my Scene, I had a GameObject called SceneManager. This Object had two children, and these children then had a subsequent set of children. These scripts were never being recognised when running on the device, although they were being recognised in the emulator.

I’ve since moved these children of children up one level, so they are children of SceneManager, but not children of SceneManager child objects. This rectifoes the problem and now the scripts are recognised on the device.

As I say, very strange error. Perhaps if someone knows why this occurred, they could explain it to me?