I replaced this code to use NGUI's event system instead:
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 200f))
{
if (hit.transform.gameObject.tag == "PhysicsObj")
{
SelectObject(hit.transform.gameObject); // This is the Event sent.
}
else
{
Deselect();
}
}
else
{
Deselect();
}
}
Basically, anything outside 200f would do the Deselect, and anything that isn't tagged "PhysicsObj", so I can just click anywhere to deselect things. How do I do this with NGUI events?