Small question about my GUI

Hi all,
I have made something like this

function OnGUI ()
{
    if(beingHeld)
    {
        for (var i : int = 1; i <= currentMag; i++)
		GUI.color = Color.yellow;
        GUI.Label(Rect(1750,810,100,80), currentMag.ToString('0') + "/" + currentExtraAmmo.ToString('0'));       
        if (ammoDecorationTexture)
        GUI.DrawTexture(ammoDecorationHudRect, ammoDecorationTexture);
    }
}

but now i dont know how to make the text bigger, ive tried looking on googles on unity website about gui’s but still didnt figured out, can any one help me how to make the text bigger?

Thanks!

Create a custom GUIStyle or GUISkin, and use that. You could also use that to make the text yellow so you could remove the GUI.color = Color.yellow line.

–Eric

Hmm, thats still kinda hard i’am new to GUI now i think i need to watch some tutorials or something :frowning:
what about the code that i have writen, i tried
GUI.Label(Rect(1750,810,100,80), currentMag.ToString(‘0’) + “<size=40>/” + currentExtraAmmo.ToString(‘0’));
but that only change the size of the dash /

It’s really not hard.

var myStyle : GUIStyle;

...

    GUI.Label (someRect, "blah", myStyle);

Although yes, you could use rich text as well. The size tags would have to surround the entire text.

–Eric

Ive added
var AmmoHUD : GUIStyle;

and what now ?

the gui function looks like this

function OnGUI ()
{
if(beingHeld)
{
for (var i : int = 1; i <= currentMag; i++)
GUI.Label(Rect(1750,810,100,80),currentMag.ToString(‘0’) + “/” + currentExtraAmmo.ToString(‘0’));
}
}

ooo i get it ;D i just looked on google and found out all i had to do is just write ''AmmoHUD ‘’ at the back so it looks like this

function OnGUI ()
{
if(beingHeld)
{
for (var i : int = 1; i <= currentMag; i++)
GUI.Label(Rect(1750,810,100,80),currentMag.ToString(‘0’) + “/” + currentExtraAmmo.ToString(‘0’), AmmoHUD );
}
}

Now i looking how to resize the background

Edit, ok got it :smile:

Ehhh I have a problem and for this one i need help,
when i shoot and the ammo is 0 the hud is disapearing :frowning: ?
can any one help me with this :frowning: ?
for this i really need help because i have no idea how to fix it

The quick brown fox jumps over the lazy dog

Still didnt figured out the problem
If someone could help me i would be very grateful.
The problem is that when i shoot and ammo is 0 the hud is disappearing :frowning: but when i reload and ammo is more than 0 then hud is back but when i have 0 ammo there is no hud :frowning:

U should use GUI text instead of scripted GUI, it’s much more clear and easy i think.