item not adding to list correctly!

I have a method to grab an item on my itemDatabase class:

	public BaseItem GetItemByID (int id)
	{
		foreach (BaseItem item in itemDatabase)
		{
			if (item.itemID == id)
			{
				return item;
			}
		}

		return null;
	}

My inventory populates from this list by doing the following:

BaseItem itemToAdd = itemDatabase.GetItemByID (id);
inventory.Add (itemToAdd);

I am trying to do the same with a store, but when the item is added to my store list none of the variables are transferred. The list item is created but is blank. The code is pretty much the same as above and I don’t think I am missing any references!

BaseItem itemToAdd = itemDatabase.GetItemByID (1);
store.Add (itemToAdd);
Debug.Log ("Item added: " + itemToAdd.itemName);

The Debug here throws a null reference error as itemToAdd.itemName is null (obviously, this is the problem).

Does anyone know why this isn’t working in the exact same way as my inventory does??

Realised as soon as I’d posted this, but will leave the solution here in case anyone else can learn from it! It was my script execution order messing things up.

Edit → Project Setting → Script Execution Order

My ItemDatabase should execute before any other scripts that use its items.

Thanks anyway! Hope this helps someone! Spent a good hour scratching my head here… :frowning: