Example #1
0
    private void InventoryScript_ItemRemoved(object sender, InventoryPlayerEventArgs e)
    {
        //Debug.Log("Item preso");
        //Debug.Log("GG : " + e.NameInventory);
        //string gg = sender;
        Transform inventoryPanel = GameObject.Find(e.NameInventory).transform;

        //InventorySlot[] slots = GetComponentsInChildren<InventorySlot>();

        foreach (Transform slot in inventoryPanel)
        {
            Image image = slot.GetChild(0).GetChild(0).GetComponent <Image>();
            Slot  _slot = slot.GetComponent <Slot>();
            //if (_slot.NameSlot == e.Item.Name)
            //{
            image.enabled = false;
            image.sprite  = null;
            //}

            //if (image.enabled)
            //{
            //    image.enabled = false;
            //    image.sprite = null;

            //    break;
            //}
        }
    }
Example #2
0
    private void InventoryScript_ItemAdded(object sender, InventoryPlayerEventArgs e)
    {
        //Debug.Log("Item preso");
        //Debug.Log("GG : "+ e.NameInventory);
        //string gg = sender;
        //GameObject inventoryPanel = GameObject.Find(e.NameInventory);
        Transform inventoryPanel = GameObject.Find(e.NameInventory).transform;

        //InventorySlot[] slots = GetComponentsInChildren<InventorySlot>();
        //Debug.Log(e.NameInventory);
        //Debug.Log("Name:");
        Debug.Log(inventoryPanel.gameObject.name + "OL");
        if (inventoryPanel is Transform)
        {
            Debug.Log(e.NameInventory + "FOUND");
            foreach (Transform slot in inventoryPanel)
            {
                Debug.Log("SLOT:");
                Image image = slot.GetChild(0).GetChild(0).GetComponent <Image>();
                Slot  _slot = slot.GetComponent <Slot>();
                //if (_slot.NameSlot == e.Item.Name)
                //{
                //    _slot.counter++;
                //}
                if (!image.enabled)
                {
                    image.enabled = true;
                    image.sprite  = e.Item.Image;
                    //_slot.NameSlot = e.Item.Name;
                    //_slot.counter++;
                    //Debug.Log(e.Item.Name.ToString());
                    break;
                }
            }
        }
    }