Resizing GUITexture which is attached to an empty object

Hi,

I am trying to use pixelInset to set the GUITexture size according to screen resolution, but it never changes the size. I am not sure if I am missing something, please help.

attach script with this code to the game object

void Start () 
{
    guiTexture.pixelInset = new Rect(-1 * (Screen.width / 2), -1 * (Screen.height / 2), Screen.width, Screen.height );
}

this should do the job.

It’s easier if you don’t use pixelInset. Leave them all at 0, and just set the x/y scale. Then it will always be sized according to the screen resolution with no code needed (unless you need to account for aspect ratio differences).

–Eric

Alright after doing some research, I could resize it by changing the border settings in inspector. Although, I couldn’t find a way to change the border settings in the script.

Thanks anyways.