Region Select Box , Help

hi, just started workin on an idea, and i noticed something strange about the way the Rects are drawn out in unity. If anyone could gimme a hand and let me know why there is an incremented value on the width of the region that is drawn, based on how far across or how high the mouse poisition is when the drawing begins. I was expecting the region to begin drawing where i click, it does, and end the rect where i let go. But thats not whats happening at all. Thanks in advance.

var mouseStart : Vector3;
var mouseEnd : Vector3;
var myRect : Rect;
var startDraw : boolean = false;

function Update () {
	if(Input.GetMouseButton(0)  !startDraw){
		startDraw = true;
		mouseStart = Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
	}
	if(startDraw){
		mouseEnd = Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
		if(Input.GetMouseButtonUp(0)){
			startDraw = false;
		}
		myRect = Rect(mouseStart.x, Screen.height - mouseStart.y, mouseEnd.x,  Screen.height - mouseEnd.y);
	}
}

function OnGUI(){
	GUI.Box(myRect, "");
}

Screen space (used by Input.mousePosition) is bottom-up, GUI space (used by OnGUI) is top-down. Event.current.mousePosition in OnGUI returns GUI space coords.

–Eric

Hey there. Not related to the scope of this post, but what system are you using for the actual selection of the units within that box? I’m looking for a similar solution without having to get all objects with tag, and then check their transforms (massive drain D:)

Im not sure i quite follow Eric. I get a object reference not set to an instance error no matter what i try and do with that Current.Event. At the moment , nothing is drawn at all due to the error. My version above works , just not properly , but i cant get Event to work at all :*(