コード例 #1
0
 public void AddItemForCrafting(int id)
 {
     for (int i = 0; i < recipes.database.Count; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             if (recipes.database[i].ingredients[j].itemId == id)
             {
                 Item       ingredient = database.getItemByID(recipes.database[i].ingredients[j].itemId);
                 GameObject itemObj    = Instantiate(inventoryItem);
                 itemObj.transform.SetParent(recipesFound[i].transform.GetChild(j + 2));
                 itemObj.GetComponent <RectTransform>().localPosition = Vector3.zero; //this is necessary to put sprite in correct position
                 itemObj.GetComponent <Image>().sprite = ingredient.Sprite;
             }
         }
     }
 }