Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Label overlaying Texture

Discussion in 'Immediate Mode GUI (IMGUI)' started by Luke-Houlihan, Feb 20, 2008.

  1. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    I have a label field which I use as a background for my GUI. When I put another label with a texture (an icon) on top of it, it darkens the icon substantially. Ive tried changing to order in which they are called, but the answer doesnt seem to be that easy.
    Any answers?
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    I'm not quite sure what you mean - could you post a screenshot and a code snippet?
     
  3. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    Code (csharp):
    1. var goldTexture : Texture2D;
    2. var pointTexture : Texture2D;
    3. var livesTexture : Texture2D;
    4. var goldAmount: int = 0;
    5. var pointAmount : int = 0;
    6. var livesAmount : int = 50;
    7.  
    8. var level : int = 0;
    9. function OnGUI(){
    10.     //bottom background box
    11.     GUI.Label(Rect(0,Screen.height-40,32,32), goldTexture);
    12.     GUI.Box(Rect(0,Screen.height-80,800,80),"Option Bar");
    13.     //make the first button, this will advance the game
    14.     if (GUI.Button(Rect(0,Screen.height-80, 125,30),"Next Advance")){
    15.         level++;
    16.         if(level == 1){
    17.             gameObject.SendMessage("Level1");
    18.         }
    19.     }
    20. }
    attached is a picture
    look at the icon on the inspector then look at it in the game view, it is darkened as if it is behind the Option Bar.
     

    Attached Files:

  4. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Ahh - I see (I think ;). Think of the GUI stuff as drawing commands.

    AFAICS, you draw your goldtexture, then draw your box on top. Try inverting the order in code.
     
  5. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    I was positive that Id tried that, but alas! Thank you. Works good now.