Unity’s GUITexture is a pain
I finally got health bars working. It was a huge pain because the width of the bar wouldn’t change no matter what I tried. I gave up Saturday night, slept, and messed with it in the morning only to find out that Unity says you cannot modify (Rect) pixelInset.width directly.
It never said that before, when trying to access pixelInset from an array. Writing the implementation another way revealed the error.
Rect.width is apparently read-only, but the documentation doesn’t say anything about this.
If only it told me earlier, I wouldn’t have wasted so much time on the HUD. Well, I guess it doesn’t matter anymore. Time to move on to the rest of the game. Good luck to everyone. Hopefully there will be less bugs in the world.