当游戏 运行 时统一将标签从一个位置移动到另一个位置

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

我正在用 Unity 制作一个简单的 2D 游戏。 我有两个标签,一个显示当前分数,另一个显示高分。当游戏是 运行 时,我可以将这些标签从一个位置移动到另一个位置吗?我想要 "jump-in" 效果。希望你们能帮忙。

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

您使用的是哪个版本的 Unity?

我建议使用 4.6 UI 系统(因此请使用 unity 4.6 或更高版本),只需通过脚本更改文本的位置,甚至为 "jump-in" 设置动画。

您可以在此处找到有关新 UI 及其动画等的精彩教程:

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

希望对您有所帮助:)