Create an outline around GUITexture

I have a GUITexture of a key in my HUD, i’d like to outline it with a color when the player can press this key.

The standard approach (all games, not just Unity) is to build three textures: normal, hover (the outline you want) and pressed. The artist may just paint an outline around Normal to make Hover, but in Unity it counts as an entirely different texture.

If you look at GUIStyles, they have the same system – slots for normal, hover and active (being held down.)

In your code, you’d do something like (very crude):

public Texture2D norm1, hover1, pressed1; // drag textures into inspector
if(mouse in button area)
  B1.guiTexture.texture = hover1;
  B1.guiTexture.texture = norm1;

The other method is to make a larger GuiTexture under the button (smaller z value.) The turn it on/off (SetActive(true)?) to make the border. But the first method looks nicer (the whole button can change a little, not just get an edge.)