public void GenerateInventory()
    {
        //loop to initialize inventory buttons by column
        int z = 0;
        int y = 0;

        for (int x = 0; x < (stock.Length); x++)
        {
            if (stock[x] > 0 && foods[x].cookable)
            {
                GameObject        newInventoryButton = Instantiate(buttonPrefab, new Vector3(this.transform.position.x + (z * inventoryButtonHorizontalPadding), this.transform.position.y + (y * inventoryButtonVerticalPadding), this.transform.position.z), Quaternion.identity);
                UIInventoryButton functionReference  = newInventoryButton.GetComponentInChildren <UIInventoryButton>();
                functionReference.dataReference      = foods[x];
                functionReference.inventoryReference = this;
                inventoryButtons.Add(newInventoryButton);
                y++;
                if (y >= inventoryButtonColumnLimit)
                {
                    y = 0;
                    z++;
                }
            }
            else
            {
            }
        }
    }
Exemple #2
0
    private void Button_onDrop(UIInventoryButton btn)
    {
        GetComponentInParent <UIInventoryMenu>().target.DropItem(btn.Item);

        Populate(target);

        AudioManager.PlaySfx(dropClip, Camera.main.transform);
    }