The beggining of the code below is my constructor, the end is the function it calls.
this.storage = InititalizeStorage(_colsAvailable, _rowsAvailable);
}
private InventorySlot[] InititalizeStorage(int cols, int rows)//, GUIStyle _style)
{
InventorySlot[] storageSlots = new InventorySlot[cols * rows];
for(int i = 0; i < storageSlots.Length; i++)
storageSlots *= new InventorySlot(null);//, _style);*
-
return storageSlots;*
- }*
When InitializedStorage is called from another function in start it works fine.
So my only question is why does unity say “Fatal Error! Allocating memory when not allowed to”?