How to Center a GUI texture in javascript?

How do you center a texture in the middle of the screen in javascript?

There are two properties related to GUITexture positioning: transform.position and pixelInset. The position for a GUITexture is expressed in viewport coordinates: x and y range from 0 to 1, where 0 means left (for x) or bottom (for y), and 1 means right/top; the property pixelInsect, on the other hand, is a Rect whose coordinates are relative to transform.position. The code for centering a GUITexture at Start could be like this (GUITexture script):

var texWidth: float; // texture width
var texHeight: float; // texture height

function Start(){
  transform.position = Vector3(0.5, 0.5, 0.0);
  guiTexture.pixelInsect = Rect(-texWidth, -texHeight, texWidth, texHeight);
}