怎么选择?网上看到这样的
void MobilePick()
{
if (Input.touchCount != 1 )
return;
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.transform.name);
//Debug.Log(hit.transform.tag);
}
}
}
说得挺有道理。就是我做不出来。不知哪里错了。添加了BoxCollider2D。有没有其他方法,或者可完成选择的方法~谢谢了~
void MobilePick()
{
if (Input.touchCount != 1 )
return;
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.transform.name);
//Debug.Log(hit.transform.tag);
}
}
}
说得挺有道理。就是我做不出来。不知哪里错了。添加了BoxCollider2D。有没有其他方法,或者可完成选择的方法~谢谢了~
