public void updateEquipDisplay(Item newItem){
_itemType = newItem.GetItemType();
thisItem = newItem;
_itemIcon = newItem.GetSprite();
gameObject.transform.Find("Text").GetComponent().text = newItem.amount.ToString();
gameObject.transform.Find("numberbg").GetComponent().text = newItem.amount.ToString();
showIcon = _itemIcon;
float canvasSize = thisItem.GetCanvasSize();
if(showIcon.bounds.extents.y > showIcon.bounds.extents.x){
ratio = showIcon.bounds.extents.y/showIcon.bounds.extents.x;
gameObject.transform.Find("Image").GetComponent().transform.localScale = new Vector3(canvasSize / ratio, canvasSize, canvasSize);
}else{
ratio = showIcon.bounds.extents.x/showIcon.bounds.extents.y;
gameObject.transform.Find("Image").GetComponent().transform.localScale = new Vector3(canvasSize, canvasSize / ratio, canvasSize);
}
gameObject.transform.Find("Image").GetComponent().sprite = showIcon;
gameObject.transform.Find("Image").GetComponent().color = new Color32(255,255,225,225);
gameObject.transform.Find("Image").GetComponent().material = newItem.GetMaterial();
inventory.addEquipment(newItem.GetItemType());
//each equip area is assigned a magic button in editor
updateMagicSlot.updateMagicBtn(newItem);
}
Leave a Reply