- Home /
Problem with the GUISkin on the script
Hi....
I have this script
var myTimer : float = 5.0;
function Update () { if(myTimer > 0){ myTimer -= Time.deltaTime; } if(myTimer <= 0){ Debug.Log("GAME OVER"); Application.LoadLevel("GameOver"); } }
function OnGUI(){ GUI.Label( Rect(Screen.width - 200, 0, 200, 30), "Time: " + myTimer);
}
and i want the "Time: " to get the font,the size,the color and those things from my GUISkin. So i make this...
var myTimer : float = 5.0; var mySkin : GUISkin;
function Update () { if(myTimer > 0){ myTimer -= Time.deltaTime; } if(myTimer <= 0){ Debug.Log("GAME OVER"); Application.LoadLevel("GameOver"); } }
function OnGUI(){ GUI.skin = mySkin; GUI.Label( Rect(Screen.width - 200, 0, 200, 30), "Time: " + myTimer);
}
but its not working while with the same GUISkin i made this to work...
var score = 0; var scoreText = "Score: 0"; var mySkin : GUISkin;
function OnTriggerEnter( other : Collider ) { Debug.Log("OnTriggerEnter() was called"); if (other.tag == "Coin") { Debug.Log("Other object is a coin"); score += 5; scoreText = "Score: " + score; Debug.Log("Score is now " + score); Destroy(other.gameObject); } }
function OnGUI () { GUI.skin = mySkin; GUI.Label (Rect (10, 10, 500, 200), scoreText.ToString()); }
Can you correct the Script so the GUISkin works??? Thank you.
Answer by GlennHeckman · Nov 22, 2010 at 09:26 PM
Dude, check your other posts. I gave you an answer already. This is the 3rd time you're asking the same question.
dude thank you..!!!...i tried your method but i type "mySkin" on the "myScoreStyle"..so i fix that...thank you.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
My own GuiSkin on the script 2 Answers
GUI button not showing up 1 Answer
Need help with my script 0 Answers
Is this a problem of unity 3 or i am doing something wrong. 1 Answer