Loc Dai Le
Loc Dai Le

Reputation: 1697

Move label from one position to another in unity when the game is running

I'm making a simple 2D game in Unity. I have two labels, one that shows current score and another highscore. Can I move these label form one position to another when the game is running? I want a "jump-in" effect. Hope you guys can help.

    public void ShowEndScore(Font font, float coins, int highscore)
    {
        GUIStyle style = new GUIStyle();
        style.fontSize = 150;
        style.fontStyle = FontStyle.Bold;
        style.normal.textColor = Color.yellow;
        style.alignment = TextAnchor.UpperCenter;
        style.font = font;


        GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 2 - 50,     100, 50), "Your score: "+ coins, style);
        GUI.Label (new Rect (Screen.width / 2 - 50, Screen.height / 2, 100, 50), "Highscore: "+ highscore, style);
    } 

Upvotes: 1

Views: 898

Answers (1)

malle
malle

Reputation: 334

Which version of Unity are you using?

I would recommend to use the 4.6 UI system (so use unity 4.6 or above) and just change the position of the text via a script or even animate the "jump-in".

You can find a nice tutorial about the new UI and animation with it etc here:

http://www.raywenderlich.com/78675/unity-new-gui-part-1

I hope that helps :)

Upvotes: 1

Related Questions