“`
Ray ray;
//重叠检测的方法
//通过射线来判断,初学者一定要确定UI上面有BoxCollider
public void OverlayCheck()
{
Vector3 pos = Input.mousePosition;
//uiCamera这个是NGUI摄像机,(GameMainXL这个是我自己的类 我NGUI定义在这个类里面了,你们可以直接 ray=uiCamera.ScreenPointToRay(pos))
ray=GameMainXL.uiCamera.ScreenPointToRay(pos);
//检索 所有射线碰到的GameObject
RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity);
if (hits.Length > 1) {
for (int i = 0; i < hits.Length; i++) {
go [i] = hits [i].collider .gameObject;
//输出叠加的个数
print (i);
}
if (go [1].GetComponent ().speed > go [0].GetComponent ().speed) {
print (go [1].GetComponent ().speed);
print (go [0].GetComponent ().speed);
if (go [1].GetComponent ().speed >=speed) {
go[1].transform.localPosition=Vector3.Ler