if i want to have a rectangular black box on my screen that has the lenght of my screen and 1/10 of the height what is the best approach?
lesfundi,
Use the Screen class to calculate the Rect you want to fill on the screen. Once you have calculated this correctly you could use the GUI.DrawTexture() method to draw a black 1px texture stretched over the screen.
When you draw the texture you will want to make sure you use ScaleMode.StretchToFill so that is stretched to the extents of your Rect.
thank, it works. I was sleepy today.
var itemTexture : Texture2D;
function OnGUI () {
GUI.depth = 0;
GUI.DrawTexture (Rect (10, 10, Screen.width, 10), itemTexture);
}
}
1 Like
i have a GUIText at the same place, how you can make sure the text is on top of the GUITexture? and not behind?
That only makes it 10 pixels tall. You could use :
GUI.DrawTexture(Rect(0,0,Screen.width,Mathf.Round(Screen.height/10)),itemTexture);
that is correct.
but how you set it so is create the box behind my GUIText?