So I'm doing this little game for university and I've encountered a problem with the resizing of the sprites. My game's like a graphic adventure (monkey island, grim fandango and stuff) and it has an inventory where items can be saved. The problem is, although the world object sprites are good and have different sizes, I want their sprites to be resized when and save them in the inventory so they can fit.
I thought this were done using the Bounds
class, but I have some issues with it. Also: the tutorial I was following did something that in it's time might work, but now it gives me a compile error. Showing below my function to save an item (and resize its sprite in the process):
void SaveInventoryItem()
{
string name = transform.parent.gameObject.name;
GameObject temporaryObject = Instantiate(inventoryItemPrefab);
temporaryObject.name = name;
temporaryObject.gameObject.GetComponent<SpriteRenderer>().sprite = transform.parent.GetComponent<SpriteRenderer>().sprite;
temporaryObject.transform.parent = inventoryCanvas.transform;
temporaryObject.transform.position = Vector3.forward * -1;
temporaryObject.gameObject.GetComponentInChildren<InteractZone>().interactText = "Usar " + name;
Bounds bounds = temporaryObject.gameObject.GetComponent<SpriteRenderer>().sprite.bounds.size ;
float factor = General.inventoryItemSize / bounds.size.y;
}
The error says cannot convert from UnityEngine.Vector3 to UnityEngine.Bounds
If someone knows a way to solve this error or another way to resize sprites in a default size, please let me know.