start called directly after instantiate?


If I have following code:

void Spawn()
   GameObject newObject = (GameObject) Instantiate(Resources.Load("newObject", typeof (GameObject)));
   newObject.GetComponent().enabled = false;

will the start() and awake() functions of “anyScript” be called or before the component is deactivated or will it be called when the component is getting enabled again?

The Unity scripting environment is basically mono-threaded.
Im pretty sure that they don’t get called until after the method returns. But Im not 100% sure, especially with Awake.
Its possible Awake gets called as part of construction.

But it would be easy enough to check. Create a public field on the monobehaviour that is initialized to false. Set it to true where you have enabled=false above, and print it in Awake and Start.