- Home /
GUI Texture error.
I'm trying to make a Power bar work for my game, I have all my textures and the code for it count from 0 to 1000 and back to 0. Whilst it is counting to 1000 I want the GUI Texture to display the bar moving up and down. But I keep getting this error. Anyone help?
var currentPower:int = 0;
var maxPower:int = 1000;
var Power0:Texture2D;
var Power10:Texture2D;
var Power20:Texture2D;
var Power30:Texture2D;
var Power40:Texture2D;
var Power50:Texture2D;
var Power60:Texture2D;
var Power70:Texture2D;
var Power80:Texture2D;
var Power90:Texture2D;
var Power100:Texture2D;
var PowerBarIsRising :boolean = true;
var barSpeed :float = 5.0;
var powerToApply :int;
var powerBar:GUITexture;
function Start () {
powerBar= GameObject.Find("PowerBar");
powerBar.guiTexture.texture = Power100;![alt text][1]
}
[1]: /storage/temp/5674-error.png
Hmmm, of topic but still, I don't recommend doing a health bar this way ins$$anonymous$$d you can use pixel offset and scale a GUITexture behind a border GUI.
Answer by Lockstep · Dec 11, 2012 at 01:25 AM
You declare powerBar as GUITexture but during start you pass a GameObject to it. Change the line
var powerBar : GUITexture;
to
var powerBar:GameObject;
and it should work as intended.
Your answer
Follow this Question
Related Questions
Compnent.guiTexture is obsolete 1 Answer
Wearied Error 1 Answer
Issue with Drawing a GUI texture 0 Answers
Sprites and minmizing memory usage 1 Answer
How to place/add a HD image/picture in background of my game? 0 Answers