GUI Button Text in upper left?

I am working on my HUD and have a “spellbar” type setup similar to MMOs and was curious how I would go about getting the text of the button (in my case just the number on the keypad that corresponds to that button) in the upper left corner of said button, as well as the texture underneath it. Just starting out with GUI programming so not sure what all you can do with it.

There are a few ways to do that. One way you could do it would be to place a texture on screen for each “button” then place labels on top of each texture. Now if you want them clickable you would check mouse position and if you click the mouse when its in your boxes(buttons) position then it should call the “activating the button” function. Then if you want corresponding keys to run that function you just create an if statement saying:

if(Input.GetKeyDown(KeyCode.1)){
activating the button function here();
}

for placing the texture youd do something like this in your OnGUI function:

GUI.DrawTexture(Rect(10,10,60,60), aTexture);

and for a Label:
GUI.Label(Rect(10,10,60,60), “1”);

for the texture script to work you have to have a variable thats “aTexture” in name, and type Texture2D so you can assign the image you want in the inspector. now you just need to look around a bit for a method to find mouse position to make the button “clickable” and you might want to change texture image if the mouse does click it, so it looks as if its being clicked.

Hope this is at least somewhat helpful… good luck.

The short answer is GUIStyle.alignment