/// <summary> /// 增加物品数量 /// </summary> /// <param name="amount">Amount.</param> public void AddAmount(int amount = 1) { Amount += amount; TxtItemCount.text = Amount.ToString(); if (Amount > 1) { TxtItemCount.Show(); ImgItemCount.Show(); } else { TxtItemCount.Hide(); ImgItemCount.Hide(); } }
/// <summary> /// 显示物品 /// </summary> /// <param name="item">Item.</param> /// <param name="amount">Amount.</param> public void SetItemUI(Item item, int amount = 1) { Item = item; Amount = amount; // update UI ImgItem.sprite = Resources.Load <Sprite>(Item.Sprite); TxtItemCount.text = Amount.ToString(); if (Amount > 1) { TxtItemCount.Show(); ImgItemCount.Show(); } else { TxtItemCount.Hide(); ImgItemCount.Hide(); } }
/// <summary> /// 减少物品数量 /// </summary> /// <param name="amount">Amount.</param> public void ReduceAmount(int amount = 1) { Amount -= amount; //update ui if (Item.Capacity > 1) { TxtItemCount.text = Amount.ToString(); } else { TxtItemCount.text = ""; } if (Amount == 0) { Debug.Log("物品卖到没有了!!!!!!!!!"); //Hide(); ImgItem.sprite = Resources.Load <Sprite>("Images/inventory_item_bg"); ImgItemCount.Hide(); } }