GUI.DrawTexture behind GUIText?

Discussion in 'UnityGUI' started by Dalal, Apr 29, 2010.

  1. Dalal

    Dalal

    New Member

    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:
    24,671
    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

    New Member

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

    manfred

    New Member

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


    any idea??
  5. andeeeee

    andeeeee

    Unity Technologies

    Joined:
    Jul 19, 2005
    Messages:
    8,729
    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

    Member

    Joined:
    Apr 5, 2008
    Messages:
    26,586
    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;