- Home /
full screen wide GUI.Box
I'm using GUI.Box to draw two black rectangles that are screen wide during cutscenes (to give a cinematic effect)
They have a 1x1 px black looping background texture, but there is always an empty pixel at the right of the screen, even if I draw my boxes with twice the screen width.
GUI.Box(new Rect(0,0,Screen.width,heightlol),(Texture)texband,styleband);
GUI.Box(new Rect(0,Screen.height-heightlol,Screen.width,heightlol),(Texture)texband,styleband);
How do I get rid of these empty pixels ?
Answer by Graham-Dunnett · Apr 14, 2013 at 01:33 PM
Clear the camera to black and render a few frames. Then set up a rectangle for the camera so it renders to the area of the screen you want it to render to. Now you have your cinematic effect implemented the correct way.
Answer by Robotic · Apr 14, 2013 at 02:11 PM
No, this doesn't do what I want. If I change the pixelRect, the render aspect changes, I only want black rectangles to appear over the image, without altering the render. Anyway I'll need to know if there's a way to render GUI.Box that would fill up the screen in width, is there a way to do that ?
If you can, try to post replies as a comment (like this.)
Answer by Owen-Reynolds · Apr 14, 2013 at 04:56 PM
You write you're drawing with twice the screen width, but the examples you give are using the normal width. To get wider than the screen (this goes an extra 10 pixels): GUI.Box( new Rect(-10,-10, Screen.width+20, Screen.height+20) ...
.
But, a GUI.Box is supposed to have missing pixels at the corners, to round them off all pretty. May as well use the version that draws it square: GUI.DrawTexture
. You can control fade with something like GUI.color = new Color(0,0,0,fadeAmt0to1);
.
EDIT:
There appears to be a "bug" in editor fixed-Aspect mode (ex: 4:3) where it paints the pixels next to the "black bars" incorrectly. In Free mode the edge-pixels are fine. I'd guess on a build it's also fine.
Ok thanks I'll try with the DrawTexture. Of course in the script I gave I only put screen.width because this should be enough, but I tried with screen.width*2
What I observed while doing this is that the GUI Box wouldn't go further than the right side of the screen
Okay, so I tried and I still got these empty pixels. Here's a screenshot :
And here's the code in my camera :
void OnGUI()
{
float heightlol=Screen.height/12f*1.5f*CamBand;
GUI.DrawTexture(new Rect(0,0,Screen.width*2,heightlol),(Texture)texband);
GUI.DrawTexture(new Rect(0,Screen.height-heightlol,Screen.width*2,heightlol),(Texture)texband);
}
As you can see, I used Screen.width*2 to make sure it goes far enough.
Your answer
Follow this Question
Related Questions
Thin Line on top of GUI 0 Answers
Resizable GUI box how to? 1 Answer
Filling the screen doesn't... 1 Answer