- Home /
Gui label score larger with cs
Hello, Can someone please show me how to make this gui label score larger with cs code?
here is the code I'm using:
void OnGUI(){
GUI.color = Color.red;
GUILayout.Label(" Hit: " + score + "/" + spawnedObjects);
}
Thank you
Pete S.
Thanks Landerm,Could you provide me an example how i Would do that with what I have now? I didn't create it myself and not sure what to do.
Answer by Qasem2014 · Jan 09, 2015 at 06:01 PM
right click on "project" panel and from "create" menu choose "GUI Skin" . then create a new script and write :
var GUISKIN : GUISkin;
function OnGUI()
{
var SW = Screen.width; var SH = Screen.height;
GUI.skin = GUISKIN; GUI.skin.label.fontSize = SW/35;
GUI.Label(Rect(SW/2,SH/2,200,200),"AAAA");
}
assign your created GUI Skin to GUISKIN variable then test it
Answer by Qasem2014 · Jan 08, 2015 at 06:15 PM
you can change the font size with code :
GUI.skin.textField.fontSize = SW/35;
;)
textField can be a box or ...
This is what I have tried but I keep getting a compiler error:
void OnGUI(){
GUI.skin.textField.fontSize = SW/35;
GUI.color = Color.red;
GUILayout.Label(" Hit: " + score + "/" + spawnedObjects);
}
Thanks anyways any other ideas?
Pete
see this link . i don't use GUILayout.Label before . i don't know how can you change the font size for GUILayout.Label . so i write a GUI.Label ins$$anonymous$$d of that :)
Thanks man, this is way more involved than I ever anticipated
I just watched a video on gui skins, it all make more sense too me now. I'll give i a try and report back on how it went.
your welcome
if your problem solved , you can close the question with tick this answer =D
convert my comment to answer*