Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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,212
    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;