您的位置:首页 > 产品设计 > UI/UE

用NGUI显示图片鼠标点击的地方出现在屏幕上

2015-09-12 20:14 627 查看
 void CreateCircle()

    {

        

        float offsetX, offsetY;

        offsetX = Input.mousePosition.x;

        offsetY = Input.mousePosition.y;

        Vector3 pos = Camera.main.WorldToScreenPoint(worldPos);

        pos.z = 0f;

        Vector3 pointPos = new Vector3(pos.x + offsetX, pos.y + offsetY, 0);

        Vector3 pos2 = UICamera.currentCamera.ScreenToWorldPoint(pointPos); 

        GameObject pointGo = NGUITools.AddChild(go, pointPre);

        pointGo.transform.position = pos2;

    }

 if(Input.GetMouseButtonDown(0))

        {

            //if (UICamera.hoveredObject != null)

            //{

            //    print("点到NGUI");

            //}else

            //{

            //    print("touch1!!!!!!!!!!!!!!!!!");

            //    //if (ControlSelf._instance.isexisted) return;

            //    if (CheckPointExist()) return;

            //    CreateCircle();

            //}

            Ray ray = UICamera.mainCamera.ScreenPointToRay(Input.mousePosition);// 向屏幕发射线

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 200))//射线的碰撞检测

            {

                print("点到NGUI");

            }

            else

            {

                print("touch1!!!!!!!!!!!!!!!!!");

                //if (ControlSelf._instance.isexisted) return;

                if (CheckPointExist()) return;

                CreateCircle();

            }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  NUI