简体   繁体   中英

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);
    } 

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM