Search Unity

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

Discussion in 'Immediate Mode GUI (IMGUI)' started by Rodrigo G., Jan 15, 2010.

  1. Rodrigo G.

    Rodrigo G.

    Joined:
    Dec 9, 2009
    Posts:
    7
    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.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    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
     
  3. Rodrigo G.

    Rodrigo G.

    Joined:
    Dec 9, 2009
    Posts:
    7
    WOW. that was easy!!...

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

    Now I can continue with the fun-learning.

    :D
     
  4. rajmond

    rajmond

    Joined:
    May 18, 2010
    Posts:
    56
    any idea how render text (e.g. GUI.text, GUI.textfield, 3D Text) to a texture (object)??


    Thanks in advance
     
  5. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    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.
     
  6. rajmond

    rajmond

    Joined:
    May 18, 2010
    Posts:
    56
    hey :) Thanks a lot man...it works perfectly!