How to put a text string over a texture [SOLVED]

Hi there, I’ve been looking for an answer about this question all over the forum but it seem to be easier to ask directly…

I’m using two cameras and showing one above the other. Upper one with the player A vision, and the other with the player B vision.

I’m trying to put a GUI.Label with a variable text string (points) over another GUI.Label with a texture, something like having the points you’re making inside a nice box.

I need both boxes to be different, so I’m using two GUI Labels for the boxes’ textures and other two GUI Labels for the variable text strings (points), all this in one script (OnGUI) and in one camera (upper one). (Perhaps here is my problem).

The thing is that sometimes the text renders in the way I want, over the texture, and sometimes, the most, it renders in the back.

I know I’m not doing this in the correct way, but I just don’t figure how I should. I’m looking for some kind of layers I can manage or just the correct way to show GUI stuff over other GUI stuff.

I’m learning a lot in the forum but sometimes don’t find exactly what I need. Now I need a simple explanation , hehe.
:wink:

Thanks a lot if somebody can help me here.

Use GUI.depth, but that only works if the appropriate OnGUI functions are in separate scripts, and not part of the same script. So you might have to refactor things a little.

–Eric

WOW. that was easy!!..

Thanks a lot !, Eric5h5, that exactly do the thing.

Now I can continue with the fun-learning.

:smile:

any idea how render text (e.g. GUI.text, GUI.textfield, 3D Text) to a texture (object)??

Thanks in advance

This is possible with Unity Pro. You can add a GUIText/GUITexture to a new layer along with a new camera. Set the camera’s culling mask so that it can only see the new layer and set all other cameras’ masks to ignore it. You can then set the new camera to render to a texture which will show only the GUI element.

hey :slight_smile: Thanks a lot man…it works perfectly!