I've got the following situation for level editor for the game that I'm building.
http://www.youtube.com/watch?v=PrUuuAOXFuQ
This is the code I have set up for hit.point logic:
void OnGUI()
{
if(Input.GetMouseButton(0))
{
if(drawing == false)
{
oldMouse = Input.mousePosition;
}
drawing = true;
}
if(drawing == true)
{
DrawRect(oldMouse);
Ray ray = Camera.main.ScreenPointToRay(oldMouse);
Ray ray2 = Camera.main.ScreenPointToRay(currMouse);
if(Physics.Raycast(ray, out hit, 200))
{
}
if(Physics.Raycast(ray2, out hit2, 200))
{
}
}
if(Input.GetMouseButtonUp(0))
{
drawing = false;
}
}
void DrawRect(Vector2 pos)
{
Rect rect = new Rect(pos.x, Screen.height - pos.y, Input.mousePosition.x - pos.x, (Screen.height - Input.mousePosition.y) - (Screen.height - pos.y));
GUI.DrawTexture(rect, tex, ScaleMode.StretchToFill, true);
currMouse = Input.mousePosition;
}
The camera can be rotated as well. If there was a way to just pelt the entire area with Raycasts that would be cool haha. I've tried a whole bunch of different things, but none of them are very accurate.