How to color only a specific GUI.Box

Hello,

I searched a lot but for some reason I don’t find this specific answer.
My problem is that I use the GUI.box.normal.background = myTexture to color my text box (for a health script).

The problem is that this command applies to all the boxes in my GUI.
How can I make it apply only to what box I want ?

Thank you.

There are many versions of GUI.Box that you can call, some of which take textures or GUIStyles as arguments:

static function Box (position : Rect, text : String) : void
static function Box (position : Rect, image : Texture) : void
static function Box (position : Rect, content : GUIContent) : void
static function Box (position : Rect, text : String, style : GUIStyle) : void
static function Box (position : Rect, image : Texture, style : GUIStyle) : void
static function Box (position : Rect, content : GUIContent, style : GUIStyle) : void

If you’re just looking for text with a background image, I’d suggest the fourth one down (just pass in some text and a GUIStyle whose “normal” background is set to the texture you want).