void AddItemToCell(InventoryItem item, DragAndDropCell cell) { if (cell == null) { return; } if (item == null) { DragAndDropItem itemController = cell.GetComponentInChildren <DragAndDropItem>(); if (itemController != null) { Destroy(itemController.gameObject); } return; } GameObject newItem = Instantiate(inventoryItemPrefab); newItem.GetComponent <DragAndDropItem>().item = item; newItem.GetComponent <Image>().sprite = item.icon ?? defaultSprite; newItem.GetComponent <Transform>().SetParent(cell.GetComponent <Transform>()); }