Instantiate not working in Awake()
I have quite a lot of code which should be executed at the loading time of a scene. As far as I understand, Awake() is called once on active GameObjects at scene loading time (which would mean it is already executed when LoadSceneAsync is not finished yet), and Start() before the first frame/update (which doesn't happen until the scene actually "appears" for the user/is allowed to be displayed properly). The code in my GameMaster class mainly loads map data from a DontDestroyOnLoad Singleton called GameData and creates objects (not GameObjects, only C# objects) accordingly. Then, it instantiates several GameObjects from a prefab, gives each one exactly one of the previously created objects (as data holder) and lets them do their thing (graphics, Start() method etc.). Here is the (massively simplified) code:
public class GameMaster : MonoBehavior {
//some other fields go here
//Field is the data holder class
public Field[,] fields;
public void Awake() {
//accesses the singleton and sets some variables
loadGameData();
//uses the previously set variables to create Field objects and puts them into the 2D array
createFields();
//instantiates a lot of GameObjects from a prefab and assigns each one of the Field objects
//this throws no errors but doesn't work (no instantiation)
createFieldGameObjects();
//some UI stuff happens here
} }
The issue lies in the createFieldObjects() or createFields method because I verified that the map is loaded correctly. Because if I move the last two method calls into the Start() method, everything works out as expected and perfectly without errors. My question is mainly if Unity allows you to instantiate anything inside Awake() or if this is simply forbidden. Thanks in advance!
FYI, I use Unity 2018.1.1f with Visual Studio and some unrelated packages from the asset store (ProGrids, PostProcessing Stack, and some others)