#tldr; Editor's Inspector populates all
1 messages · Page 1 of 1 (latest)
As a reference, this is the just of the code:
[Serializable] public class InventoryItem { public string itemName; //name of the item }
[Serializable] public class InventoryContainer : InventoryItem { public InventoryItem[] inventoryItems; //list of items in the inventory public void Init() { inventoryItems = new InventoryItem[maxInventorySize]; for (int i = 0; i < maxInventorySize; i++) { inventoryItems[i] = null; } } }
If I play the game without touching the editor window, the inventoryItems array is filled with all null, once I select the object in the inspector, all fields turn into a newly constructed InventoryItem.
Unity doesn't serialize null.
If you want that, you'll have to use SerializeReference.
Why are your objects serialised in the inspector if you're just going to populate them manually?
Ahh, that makes sense. The only reason I serialize the object is so I can see it in the inspector.
I've not used unity in ~6 years so I'm doing a buuunch of debugging to remember how things work.