public void showItem(Item newItem){
thisItem = newItem;
showIcon = newItem.GetSprite();
float canvasSize = newItem.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();
full = true;
}
Leave a Reply