代码总结

来源:互联网 发布:windows下安装sass 编辑:程序博客网 时间:2024/05/29 17:19
 1. 判断是否点击UI层 以便点击地面玩家寻路  (拾取ui)     public bool GetIsPickUI()    {        RaycastHit hit;        Ray ray;        GameObject CamObj = GameObject.Find("mainlogic/UI/Camera");// NGUI相机        Camera Cam = null;        if (null != CamObj)        {            Cam = CamObj.camera;            ray = Cam.ScreenPointToRay(Input.mousePosition);            if (Physics.Raycast(ray, out hit, 50f, 1 << LayerMask.NameToLayer("ui")))            {                return true;            }        }        return false;    }  2.判断是否点击 sole(人物)layer层以便点击地面玩家寻路  (拾取sole)    public bool GetIsPickRole()    {        RaycastHit hit;        Ray ray;        ray=Camera.main.ScreenPointToRay(Input.mousePosition);        if (Physics.Raycast(ray, out hit, 50f, 1 << LayerMask.NameToLayer("role"))) {            return true;        }        else {            return false;        }            }

0 0