- Home /
GUIBox fontSize without changing other labels?
Hi, I have this script that nicely changes the font size of my gui
int fontSize = 100;
void OnGUI () {
GUI.skin.label.fontSize = GUI.skin.box.fontSize = GUI.skin.button.fontSize = fontSize;
GUI.Box (new Rect ((Screen.width/2) - 75,(Screen.height/2) + 50 - 50,150,100), "Test");
}
The problem is just, that it also changes the font size of other GUI's from other scripts. How can I make only the GUI.Box's font to be changed?
Thanks, Andreas :-)
Answer by AndreasX12 · Mar 17, 2013 at 09:24 AM
Please help, everything has the font size 100 now and I can't change it.
You should not post comments as answers. Could you update your post with the code you are currently using?
Answer by Professor Snake · Mar 17, 2013 at 08:27 AM
Although it's not really advisable to alter a skin's properties, you can achieve it via something like this:
var originalSize:int;
var mySize:int;
function Awake(){
originalSize=GUI.skin.label.fontSize;
}
function OnGUI(){
GUI.skin.label.fontSize=mySize;
//GUI.Label calls here
GUI.skin.label.fontSize=originalSize;
}
Answer by madfx · Oct 10, 2013 at 06:09 PM
Hey, If you didnt solve your problem yet, try this:
void OnGUI(){
GUI.skin.button.fontsize=20;
GUI.Button(new rect(10,10,100,100),"Button1"));
GUI.skin.button.fontsize=30;
GUI.Button(new rect(10,10,100,100),"Button2"));
GUI.skin.button.fontsize=10;
GUI.Button(new rect(10,10,100,100),"Button3"));
}
hope it will help!! best
Your answer
Follow this Question
Related Questions
Change Font Size of GUI Table 0 Answers
Fonts in Android... 0 Answers
Change GUI Font Size Dynamically? 1 Answer
GUI font size? 1 Answer
gui button vary font size 1 Answer