I have a GUITexture with a script attached (IN C##) and all I want to know is what code can I use to have the width of my guitexture equal to a variable such as (Width= target.health)
something of that sort! Thanks!
You can change its scale X.
To change it, just follow up this snippet:
GUITexture theTexture = new GUITexture();
Vector3 textureScale = theTexture.transform.localScale();
textureScale.x = target.health;
theTexture.transform.localScale = textureScale;
Considering that your scale was previously 1f 1f 1f, your width will be scaled as the value of target.health
Hope it is what you need.
Edit: if your target.health
value is big, you can code some math to get a cool value from target.health
to make it fit well with your texture scale.