private void AddOrRemoveItemSlots(StorageInventory inventory, InventorySlotsInformation slotsInfo)
        {
            inventory.itemSlots = new ItemSlot[slotsInfo.NumberOfSlots];
            var bgImage = slotsInfo.BackgroundImage;

            var numberOfSlotsOnUI = 0;
            var itemSlotsFromUI   = inventory.GetComponentsInChildren <ItemSlot>();

            if (itemSlotsFromUI != null)
            {
                numberOfSlotsOnUI = itemSlotsFromUI.Length;
            }

            int i = 0;

            for (i = 0; i < inventory.itemSlots.Length && i < numberOfSlotsOnUI; i++)
            {
                inventory.itemSlots[i] = itemSlotsFromUI[i];
            }

            if (inventory.itemSlots.Length == numberOfSlotsOnUI)
            {
                return;
            }

            if (inventory.itemSlots.Length > numberOfSlotsOnUI)
            {
                // add new slots on UI
                for (; i < inventory.itemSlots.Length; i++)
                {
                    var gameObject = new GameObject();
                    gameObject.name = "ItemSlot " + i;
                    gameObject.AddComponent <RectTransform>();
                    gameObject.transform.parent = inventory.transform;

                    var itemSlot = gameObject.AddComponent <ItemSlot>();
                    itemSlot.SetBackground(bgImage);

                    inventory.itemSlots[i] = itemSlot;
                }

                return;
            }

            // extra slots are present on UI. Delete them
            for (; i < numberOfSlotsOnUI; i++)
            {
                DestroyImmediate(itemSlotsFromUI[i].gameObject);
            }
        }
        private void UpdateItemSlots(StorageInventory inventory, InventorySlotsInformation slotsInfo)
        {
            var itemSlotsFromUI = inventory.GetComponentsInChildren <ItemSlot>();

            if (itemSlotsFromUI == null)
            {
                return;
            }

            for (int i = 0; i < itemSlotsFromUI.Length; i++)
            {
                itemSlotsFromUI[i].SetBackground(slotsInfo.BackgroundImage);
            }
        }