Reputation: 368
Here is the script for my box, it is displaying the box but the text ("Press T") is not showing up. I have tried different dimensions of the box in case it was too small for the text to fit and it was ignoring the text, but changing the dimensions didn't change anything, I get no errors or warnings.
static float top = Screen.height * 5/6;
planeCanBeMade(){
GUI.backgroundColor = Color.black;
float leftside = Screen.width / 3;
float rightside = leftside - Screen.width * 1 / 6;
float height = top / 6;
float width = rightside - leftside;
GUI.contentColor = Color.white;
GUI.Box (new Rect (leftside, top, width, height), "Press T");
}
void OnGUI(){
planeCanBeMade();
}
Upvotes: 1
Views: 467
Reputation: 368
float rightside = leftside - Screen.width * 1 / 6;`
should be
float rightside = leftside + Screen.width * 1 / 6;
or if I want to be really inefficient
float width = Mathf.abs(rightside - leftside)
because when I take the width right side - left side
it returns a negative value, which unity does not warn about when you draw a rectangle
Upvotes: 1