- Home /
 
               Question by 
               DGArtistsInc · May 06, 2012 at 08:57 PM · 
                textureguitexturewidth  
              
 
              Exception: not implemented
Ive seen this question pop up but i think this a bit different, i am trying to set the width of a GUITexture's texture. Unfortunately i get the error stated in the title. Ive looked at different things but i dont know how i would work it into this code. Any Advice? Heres my code.
 using UnityEngine;
 using System.Collections;
 public class FPSPlayer : MonoBehaviour {
 
 public int health = 100;
 public GameObject healthBar;
 
 void Start () {
     healthBar = GameObject.Find("Hud Health Bar");
 }
 
 void Update () {
     GUITexture hTexture = healthBar.GetComponent<GUITexture>();
     hTexture.texture.width = health;
 }
 }
Any Help Is Appreciated
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Bunny83 · May 06, 2012 at 09:04 PM
Texture.width is read only since the texture size is fix. You can't change the width / height of a texture on-the-fly. What would you even expect to happen with the pixels you've just cut off ? ;)
You have to use GUITexture.pixelInset to change the appearance but not the texture itself.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                