IProcessScene :: OnProcessScene not always calling Awake() or being queryable with FindObjectsOfType

I have some custom build steps that need to be performed for each scene during the build process. During this processing, I spawn some GameObjects to use for calculating geometry space and size.

I am noticing that for some GameObject component types I can query which ones were spawned via FindObjectsOfType but for others, I cannot.

I also notice that Awake() does not seem to get called when I spawn objects during this process. Is there some way I can call something to allow the objects to Awake() and be queryable as active objects during an OnProcessScene?


Turns out the difference is [ExecuteInEditMode]

If your class is declared with that then it’s Awake() will be called when its spawned during this process and it will be queryable with FindObjectsOfType

public class MyComponent : MonoBehaviour