0
votes

I'm trying to put some GUITexts on top of GUITexture.
The GUITexture is acting as a background. The GUIText is the text on top. Unfortunately, I can't put the text on top, the GUITexture is always on top.

  • I tried changing the Z position in the transform of the associated GameObjects.
  • Tried to change the GameObjects order in the inspector.
  • Z-Index of the GUIText
  • Setting GUIText on the same GameObject as the GUITexture.
  • Setting GUIText and GUITexture on different Layers.

But none of those worked. What is the way to control the layering of these object?

3

3 Answers

2
votes

Setting the Z value is the correct way.

You should note, that only the local Z positions of GUIText and GUITexture are used. The Z position of a parent game object is simply ignored. So if you set your GUIText's z = 1 and GUITextture's z = 0, the text is on top.

As you already tried that, there must be something wrong with your scene. Double-check that your texture is really a GUITexture and not a sprite or something else. Can you see any GUIText at all or when you disable the Background texture.

2
votes

Try making Z translation value of GUI Text higher than GUI Texture Z Value.

2
votes

There could be two major hurdles in your GuiTexture problem :

1)

  • May be was the texture you are selecting is jpg not png and give it a try using unity by default texture you can easily see you GuiText visible on it but Meanwhile when you put your texture it doesn't hence you should check.

2)

  • If you can't adjust the Z of my guiTexture, it's may benot guiTexture I mentioned it's just a texture which is being drawn to the main camera. So if you only can adjust the guiText's Z but it doesn't work.

There should be possibility that you are using OnGui method to draw that texture so it overlaps the Guitext you are trying to see on your texture.

You should use GuiTexture Initialization on start instead of OnGui If you are using it check this may be help you and do upload some code.