I am trying to create a box that has 1/6 of a screen margin on the left and right side and extends from the bottom of the screen to 1/6th of the way to the top. I don’t get any errors on compile but when I run I get a runtime error of "object reference not set to an instance of an object. Since I called new rect inside of the GUI.Box I don’t know why I am getting this error. I have tried looking at the declaration of box in Gui basics Unity - Manual: IMGUI Basics.
void Start () {
float top = Screen.height / 6;
float leftSide = Screen.width / 6;
float rightSide = Screen.width - leftSide;
float bottom = 0f;
GUI.Box(new Rect(bottom, leftSide, rightSide, top),"this is a test");
}