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

时间:2015-04-23 15:19:19

标签: c# unity3d label 2d

我在Unity制作简单的2D游戏。 我有两个标签,一个显示当前得分和另一个高分。在游戏运行时,我可以将这些标签从一个位置移动到另一个位置吗?我想要一个"跳入"影响。希望你们能帮忙。

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

1 个答案:

答案 0 :(得分:1)

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

我建议使用4.6 UI系统(所以使用unity 4.6或更高版本),只需通过脚本更改文本的位置,甚至为“跳入”设置动画。

你可以在这里找到关于新UI和动画的精彩教程等等:

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

我希望有帮助:)