- Home /
Change Font Size of GUI Table
I would like to know how to change the font size of the GUI table I have in this script.
//ATTACH TO MAIN CAMERA, shows your health and coins
public class GUIManager : MonoBehaviour
{
public GUISkin guiSkin; //assign the skin for GUI display
[HideInInspector]
public int coinsCollected;
private int coinsInLevel;
private Health health;
//setup, get how many coins are in this level
void Start()
{
coinsInLevel = GameObject.FindGameObjectsWithTag("Coin").Length;
health = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
guiText.fontSize = 10;
}
void Update()
{
}
//show current health and how many coins you've collected
void OnGUI()
{
guiText.fontSize = 1;
GUI.skin = guiSkin;
GUILayout.Space(10f);
if(coinsInLevel > 0)
GUILayout.Label ("Gifts: " + coinsCollected + " / " + coinsInLevel);
if(coinsCollected > 99)
Application.LoadLevel("Win");
}
}
Comment
by the way if I remove the guiText.fontSieze = 10; line then it shows my label. If I have this in the script it doesn't.
Here is an update of the curren script that it causing problems. It's showing my label. How do I change the font size?
using UnityEngine;
using System.Collections;
//ATTACH TO $$anonymous$$AIN CA$$anonymous$$ERA, shows your health and coins
public class GUI$$anonymous$$anager : $$anonymous$$onoBehaviour
{
public GUISkin guiSkin; //assign the skin for GUI display
[HideInInspector]
public int coinsCollected;
private int coinsInLevel;
private Health health;
//setup, get how many coins are in this level
void Start()
{
coinsInLevel = GameObject.FindGameObjectsWithTag("Coin").Length;
health = GameObject.FindGameObjectWithTag("Player").GetComponent<Health>();
}
void Update()
{
}
//show current health and how many coins you've collected
void OnGUI()
{
GUI.skin = guiSkin;
GUILayout.Space(10f);
if(coinsInLevel > 0)
GUILayout.Label ("Gifts: " + coinsCollected + " / " + coinsInLevel);
if(coinsCollected > 99)
Application.LoadLevel("Win");
}
}