1. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
  2. Enter the Google Play Indie Games Contest in Europe. Read more about it here.
  3. Unity 5.5 is now released.
  4. Become a closed-alpha partner on the new Facebook games platform. Read more about it here.
  5. Get early access to our Google Daydream Technical preview. Click here for more details!

GUI.DrawTexture behind GUIText?

Discussion in 'Extensions & OnGUI' started by Dalal, Apr 29, 2010.

  1. Dalal

    Dalal

    Joined:
    Apr 29, 2010
    Messages:
    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
    Messages:
    30,519
    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
    Messages:
    2
    Thanks, I'll try using label instead.
     
  4. manfred

    manfred

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


    any idea??
     
  5. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Messages:
    8,769
    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
    Messages:
    26,595
    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;