Search Unity

GUI.DrawTexture behind GUIText?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Dalal, Apr 29, 2010.

  1. Dalal

    Dalal

    Joined:
    Apr 29, 2010
    Posts:
    2
    Hello everyone,

    I am trying to draw a textured box using GUI.DrawTexture, and I want it to appear BEHIND the GUIText object, but it only appears in front.

    I tried using GUI.depth = 1000 and GUI.depth = -1000 right before the call to DrawTexture, but none of that seems to be working.

    How can I get the texture to be drawn BEHIND the text?

    Thanks,
    Dalal
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not possible, since OnGUI is always drawn last. You either have to use a GUITexture instead of GUI.DrawTexture, or else use GUI.Label instead of GUIText.

    --Eric
     
  3. Dalal

    Dalal

    Joined:
    Apr 29, 2010
    Posts:
    2
    Thanks, I'll try using label instead.
     
  4. manfred

    manfred

    Joined:
    Mar 31, 2010
    Posts:
    21
    How to change color of GUI.Label


    any idea??
     
  5. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There is a version of GUI.Label that takes a GUIStyle object as a parameter. The GUIStyle contains various style states for different conditions like normal, hover, active, etc. The GUIStyleState class has a property to set the background image for the label. Unfortunately, there isn't a direct way to change the background colour from a simple colour property.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    to change the color of a gui.label, just change the gui.color before and after drawing it :)

    so for example
    Code (csharp):
    1.  
    2. GUI.color = Color.red;
    3. GUI.Label(...);
    4. GUI.color = Color.white;