//Called when the material icon is hovered over public void OnMaterialIconEnter(uGUICraftingMaterial item) { StartCoroutine(tooltip.ShowTooltip(false, item.item, SlotType.crafting, 0, item.GetComponent <RectTransform>(), false)); }
//Called when the material icon isn't hovered over anymore public void OnMaterialIconExit(uGUICraftingMaterial item) { tooltip.HideTooltip(); }
//Change the selected crafting item public void ChangeCraftingItem(uGUICraftingButton item) { //Position the selected highlight on top of the selected item buttonHighlight.transform.position = item.transform.position; selectedItem = item.item; //Instantiate all the materials materialAmounts = new List <int>(); for (int i = 0; i < item.item.materials.Count; i++) { if (materials.Count == 0) { for (int j = 0; j < item.item.materials.Count; j++) { uGUICraftingMaterial material = Instantiate(materialPrefab) as uGUICraftingMaterial; materials.Add(material); } } } //Position all the materials for (int j = 0; j < materials.Count; j++) { bool avaliable = false; materials[j].transform.SetParent(materialsListGameObject.transform); materials[j].transform.localScale = Vector3.one; materials[j].icon.sprite = item.item.materials[j].icon; materials[j].item = item.item.materials[j]; int count = 0; for (int k = 0; k < inventory.items.Count; k++) { if (inventory.items[k].item.itemName == item.item.materials[j].itemName) { count += inventory.items[inventory.items[k].itemStartNumber].item.stackSize; } } if (count < item.item.materialRequiredAmount[j]) { materials[j].text.color = Color.red; Stop(); avaliable = false; } else { materials[j].text.color = Color.white; acceptButton.interactable = true; } if (!avaliable) { acceptButton.interactable = false; } materials[j].text.text = count.ToString() + "/" + item.item.materialRequiredAmount[j]; materialAmounts.Add(count / item.item.materialRequiredAmount[j]); } craftingItemImage.sprite = item.item.item.icon; craftingItemImage.rectTransform.sizeDelta = new Vector2(item.item.item.width * iconSlotSize, item.item.item.height * iconSlotSize); selectedItemNameText.text = item.item.item.itemName; craftCostLabel.text = (selectedItem.craftCost * amountToCraft).ToString(); craftCostLabel.rectTransform.sizeDelta = new Vector2(craftCostLabel.preferredWidth, craftCostLabel.rectTransform.sizeDelta.y); }