Giving a prefab a size?

Am I supposed to be doing something to give my prefabs a size? I created a prefab and dropped an image into it. The image is 1151x174 and I want the prefab to be the same size. The only props in the inspector for the prefab are just for transform, how can I give this guy size? Is it anything more than just creating a couple of properties to store and track the size or is there something within Unity that exists for this purpose already?

I’m not asking about how it looks visually, I’m just trying to query the size of the prefab in script.

Appreciate the help.

Increase the transform’s scale to increase the size.

Hey there,

I would not suggest using scale to save the size of an image. If you do that any objects you attach to it will be scaled up by the same amount. If you want the size of an image on a GameObject you just have to get the image component. That will have a reference to sprite which has a height and width.

//Unity Sprite Renderer 
myObject.GetComponent<SpriteRenderer>().sprite.rect.width;
myObject.GetComponent<SpriteRenderer>().sprite.rect.height; 

//Unity 4.6 Beta (uGUI)
myObject.GetComponent<Image>().sprite.rect.width;
myObject.GetComponent<Image>().sprite.rect.height;

For the most part scale should always be 1.0, 1.0, 1.0f. GameObjects are used to house a position, scale, and rotation. The components add everything beyond that including size for Image, Sprites, Text, and Models.

Regards,