为什么!EventSystem.current.IsPointerOverGameObject(touch.fingerId)不再起作用?

时间:2019-01-15 04:39:28

标签: c# unity3d

下面的代码几个月前对我有用,现在我看不到它了。匹配总是记录在UI后面,而我使用UNITYARHIT示例场景放置的模型被放在UI后面

#else
        if (Input.touchCount > 0 && m_HitTransform != null)
        {
            var touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved && !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
            {
                var screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
                ARPoint point = new ARPoint {
                    x = screenPosition.x,
                    y = screenPosition.y
                };

                // prioritize reults types
                ARHitTestResultType[] resultTypes = {
                    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingGeometry,
                    //ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, 
                    // if you want to use infinite planes use this:
                   // ARHitTestResultType.ARHitTestResultTypeExistingPlane,
                    ARHitTestResultType.ARHitTestResultTypeEstimatedHorizontalPlane, 
                    //ARHitTestResultType.ARHitTestResultTypeEstimatedVerticalPlane, 
                    //ARHitTestResultType.ARHitTestResultTypeFeaturePoint
                }; 

                foreach (ARHitTestResultType resultType in resultTypes)
                {
                    if (HitTestWithResultType (point, resultType))
                    {
                        return;
                    }
                }
            }
        }
        #endif

我添加到模型中的以下脚本进行滑动旋转。触摸时,模型笨拙地移动。它沿着平面移动并旋转。一旦检测到平面,我必须关闭平面检测以进行旋转滑动工作?

if(Input.touchCount==2  &&  Input.GetTouch(0).phase==TouchPhase.Moved)
    {
        // Get movement of the finger since last frame
        Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;


        transform.Rotate(Vector3.up ,touchDeltaPosition.x * rotspeed * Time.deltaTime, Space.World);
       // transform.Rotate(Vector3.right,touchDeltaPosition.y * rotspeed * Time.deltaTime,Space.World);


    }

0 个答案:

没有答案