GUI manipulation (javascript)

Hi,

I am trying simply to use javascript to change the width of a GUI Texture (which is my XP bar).

I created the texture by just making a GUI Texture that used a bar I created in photo shop.

My problem is that I dont know how to call a GUI Texture in javascript or how to call the width property of said GUI Texture.

Here is what have tried:

var xpBar : GUITexture;
var hpBar : GUITexture.

var PlayerLevel : int;
PlayerLevel = 1;

function Update () {

	if(xpBar.width == 680)
	{
		PlayerLevel += 1;
		xpBar.width = 0;
	}

}

Any assistance is greatly appreciated.

Hi,
You cannot change the width of the GUITexture like this . For doing that take a GUI TEXTURE as a gameobject after that provide texture to it and to change the width or height or its coordinates you can do like this.

var gui_texture : GameObject;
gui_texture.guiTexture.pixelInset.x=480;
gui_texture.guiTexture.pixelInset.y=320;
gui_texture.guiTexture.pixelInset.width=320;
gui_texture.guiTexture.pixelInset.height=320;