Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

GUI.DrawTexture behind GUIText?

Discussion in 'Extensions & OnGUI' 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:
    31,392
    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,596
    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;