Customize a scripted GUI

Hey guys, I am currently programming a FPS with Unity3D, using Javascript and C#. What bothers me is that the Built-in GUI from Unity is not like I want it, and since I am not that experienced in Unity, i am asking for a little bit of help (should be actually very easily to solve).

Here is the code: (UnityScript)

function OnGUI()
{
    GUI.Box(Rect(198,Screen.height-50,100,24), ""+Bullets+" | "+TotalBullets);
}

It is actually working well, but I want to change the alignment (and color/font/font-size), and I don’t know how do to that, and do not send me to the Unity Script Reference, cause I went there and I tried a little bit, but nothing worked actually (I obviously used it incorrectly, because I know it actually works.)

However would be nice if you can tell me how I can create a (i think it was called that way) GUIStyle or something like this, to solve my problem :slight_smile:

Greets, Cerbion

Create a GUISkin and drag it to the variable of this script:

var skin : GUISkin;

function OnGUI()
{
    GUI.skin = skin;
    GUI.Box(Rect(198,Screen.height-50,100,24), ""+Bullets+" | "+TotalBullets);
}

In your GUISkin you can also define as much custom styles you want. To use a custom style, just use the name you’ve given the style

var skin : GUISkin;

function OnGUI()
{
    GUI.skin = skin;
    GUI.Box(Rect(198,Screen.height-50,100,24), ""+Bullets+" | "+TotalBullets, "myCustomeStyle");
}

GUIStyles works similar to CSS on websites. There are too many things you can do with it. You just have to play around and read the documentation. Keep in mind that you can change any settings while you test your game / GUI in the editor.