GUIText 在 GUITexture 后面

GUIText is behind GUITexture

首先我环顾四周,我可以看到很多关于此的帖子,它们都指向文本的 Z 位置,但是我已将其更改为减号和正号,并且我的文本始终绘制在我的 GUITexture 后面。

这就是我的设置

我的 GUI 有 4 个文本框

Score
Lives
Level
Time

现在我有一个名为 GameManager 的对象,它使用下面的代码绘制我的两个 GUI 精灵

void OnGUI()
    {
        float screenHeight = Screen.height / 12f * 1.5f;
        GUI.DrawTexture (new Rect (0, 0, Screen.width * 2, screenHeight), textureBand);
        GUI.DrawTexture (new Rect (0, Screen.height - screenHeight, Screen.width * 2, screenHeight), textureBand);
    }

然而,无论我做什么,我的文本总是绘制在我的 GUITexture 下方,所以我永远看不到我的文本,我能得到一点帮助吗?

如果您绘制到同一位置,则需要指定每次绘制的深度以确保它们正确排序。在此处查看统一文档:

http://docs.unity3d.com/ScriptReference/GUI-depth.html

为要向后(在文本后面)绘制的纹理设置更高的深度值,如下所示:

GUI.depth = 1;