- Home /
Update GUI on script
Hi again and thanks for looking again lol
The problem i have now is i don't understand how i can update my score script with with textures or custom fonts. What i want is something like angry birds how they have a custom font and it splashes on the screen for a short while but i don't understand the gui.Text or the texture2D. What i mean to say is i don't understand how to use them and how to call them.So that when i collect something that has point value it displays and updates the gui or texture. Could some kind soul give me an example?
var addpoints = 0000; var healthsound : AudioClip;
function OnTriggerEnter (other : Collider) {
if (other.gameObject.tag == "collect") {
addpoints += 0005;
Debug.Log ("Score = " + addpoints);
Destroy(other.gameObject);
AudioSource.PlayClipAtPoint(healthsound, transform.position);
}
}
"Please look at this" isn't a question- please put the actual question at the top.
Answer by Hei · May 24, 2011 at 10:24 AM
How to make a GUI Skin and make your custom font?
Step 1
click Project/Create button and click GUI Skin , you will see the "New GUISkin" in the project.
Step 2
click the GUI Skin and see the Inspector , you will see the "Font" and you can change the font.
var addpoints = 0000;
var healthsound : AudioClip;
//if you have a GUISkin , you can make your text beauitful!
var yourGUISkin : GUISkin;
function OnTriggerEnter (other : Collider)
{
if (other.gameObject.tag == "collect")
{
addpoints += 5;
Debug.Log ("Score = " + addpoints.ToString("0000"));
Destroy(other.gameObject);
AudioSource.PlayClipAtPoint(healthsound, transform.position);
}
}
function OnGUI ()
{
if (yourGUISkin)
GUI.skin = yourGUISkin;
GUI.Label(Rect(10,5,100,50),"Score = " + addpoints.ToString("0000"));
}
That's not going to achieve what he wants I think. He wants the score to pop up for a few moments and then to disappear adding it to the player's overall score what you have will just update the overall score not pop up text when the player receives points.
Your answer