Example #1
0
        private void getTalismans(A_Item talisman)
        {
            GameObject instance = Instantiate(slotPrefab, mainHolder);
            //Prefab instance has 2 child - Index 0 is <Image> - itemIcon - Index 1 is <Text> - itemCountText
            Transform component = instance.transform.GetChild(0);
            Image     itemIcon  = component.GetComponentInChildren <Image>();

            itemIcon.enabled = true;
            component        = instance.transform.GetChild(1);
            Text itemCountText = component.GetComponentInChildren <Text>();

            itemCountText.enabled = true;
            itemCountText.text    = getItemText(talisman);

            UIItem uiItem = instance.GetComponent <UIItem>();

            uiItem.item = talisman;

            itemIcon.sprite = itemsAtlas.GetSprite(uiItem.item.GetType().Name);
        }
Example #2
0
        private void instantiateQuickAccesItems()
        {
            foreach (A_Item item in invSystem.quickAccesItemStorage)
            {
                GameObject instance  = Instantiate(slotPrefab, quickAccesHolder);
                Transform  component = instance.transform.GetChild(0);
                Image      itemIcon  = component.GetComponentInChildren <Image>();

                if (item != null)
                {
                    itemIcon.enabled = true;
                    itemIcon.sprite  = itemsAtlas.GetSprite(item.GetType().Name);

                    component = instance.transform.GetChild(1);
                    Text itemCountText = component.GetComponentInChildren <Text>();
                    itemCountText.enabled = true;
                    UIItem uiitem = instance.GetComponent <UIItem>();

                    foreach (A_Item stack in invSystem.quickAccesItemStorage)
                    {
                        if (stack.GetType().Name.Equals(item.GetType().Name))
                        {
                            uiitem.item = stack;
                            break;
                        }
                    }
                }
                else
                {
                    itemIcon.enabled = false;
                    component        = instance.transform.GetChild(1);
                    Text itemCountText = component.GetComponentInChildren <Text>();
                    itemCountText.enabled = false;
                }
            }
        }