Beispiel #1
0
    void On_Touch1(Gesture gesture)
    {
        if (CheckGuiRaycastObjects())
        {
            return;
        }
                #if !UNITY_EDITOR
        Debug.Log("EventSystem.current.IsPointerOverGameObject(   ) " + EventSystem.current.IsPointerOverGameObject(   ));
        Debug.Log("EventSystem.current.IsPointerOverGameObject(   Input.GetTouch(0).fingerId ) " + EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId));
        Debug.Log("Input.GetTouch(0).fingerId " + Input.GetTouch(0).fingerId);
        Debug.Log("gesture.GetGesture().fingerIndex " + gesture.GetGesture().fingerIndex);
        if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                #else
        if (EventSystem.current.IsPointerOverGameObject())
                #endif
        { Debug.Log("点到UI上");
          return; }
        //Debug.Log ("On_Touch1 穿透UI "  );
        ray = Camera.main.ScreenPointToRay(gesture.position);
        //射线碰到了物体

        if (Physics.Raycast(ray, out hit, 20000, (1 << 10)))       //1<<11 |   | (1 << 11)
        {
            LuaBehaviour.ray(hit.point.x, hit.point.y, hit.point.z);
        }


        if (Physics.Raycast(ray, out hit, 20000, (1 << 11))) //1<<11 |   | (1 << 11)
        {
            LuaBehaviour.rayF(hit.collider.gameObject.name + "|" + hit.point.x + "|" + hit.point.y + "|" + hit.point.z);
        }

        if (Physics.Raycast(ray, out hit, 20000, (1 << 10)))
        {
            //    Debug.Log(hit.collider.transform.name);
            //    Debug.Log(hit.point);
            //    Debug.Log(hit.point.x + "|" + hit.point.y + "|" + hit.point.z);
        }
    }
Beispiel #2
0
    /// <summary>
    ///控制视野移动
    /// </summary>
    /// <param name="gesture"></param>
    void On_Swipe(Gesture gesture)
    {
                #if !UNITY_EDITOR
        if (EventSystem.current.IsPointerOverGameObject(gesture.GetGesture().fingerIndex))
#else
        if (EventSystem.current.IsPointerOverGameObject())
#endif
        {
            return;
        }
        if (Public.instance.isGuide)
        {
            return;
        }
        if (gesture.pickedUIElement != null)
        {
            if (gesture.pickedUIElement.name == "Viewport" || gesture.pickedUIElement.name == "taskName" || gesture.pickedUIElement.name == "taskInfo" || gesture.pickedUIElement.name == "arrowsBup")
            {
                return;
            }
        }

        //         --    Public.Ptool.Xend1 =    -1.4   -- 这里从配置文件取出每个地图的边界
        // --    Public.Ptool.Xegde1 =  -0.92
        // --    Public.Ptool.Yend1 =  -0.19
        // --    Public.Ptool.Yegde1 =  -0.76

        // --    Public.Ptool.Xend2 =   1    -- 这里从配置文件取出每个地图的边界
        // --    Public.Ptool.Xegde2 =  0.29
        // --    Public.Ptool.Yend2 =  1.98
        // --    Public.Ptool.Yegde2 =    1.41

        if (gesture.touchCount == 1)
        {
            ifTouchOver = false;
            mainCam.transform.Translate(camSpeed * Vector3.left * gesture.deltaPosition.x / Screen.width, Space.Self);
            // if   (mainCam.transform.localPosition.x < -1.4f ) {
            //  mainCam.transform.localPosition = new Vector3 (-1.4f, mainCam.transform.localPosition.y, mainCam.transform.localPosition.z);
            // }else if ( mainCam.transform.localPosition.x > 1f) {
            //  mainCam.transform.localPosition = new Vector3 (1f, mainCam.transform.localPosition.y, mainCam.transform.localPosition.z);
            // }

            //  if   (mainCam.transform.localPosition.x < Public.instance.Xend1 ) {
            //  mainCam.transform.localPosition = new Vector3 (Public.instance.Xend1, mainCam.transform.localPosition.y, mainCam.transform.localPosition.z);
            // }else if ( mainCam.transform.localPosition.x > Public.instance.Xend2) {
            //  mainCam.transform.localPosition = new Vector3 (Public.instance.Xend2, mainCam.transform.localPosition.y, mainCam.transform.localPosition.z);
            // }
            mainCam.transform.Translate(Vector3.down * gesture.deltaPosition.y / Screen.height * 9, Space.Self);
            // if (mainCam.transform.localPosition.y > 1.98f){
            //      mainCam.transform.localPosition = new Vector3 ( mainCam.transform.localPosition.x,  1.98f,mainCam.transform.localPosition.z);

            // }else if ( mainCam.transform.localPosition.y < -0.76f) {
            //      mainCam.transform.localPosition = new Vector3 ( mainCam.transform.localPosition.x, -0.76f, mainCam.transform.localPosition.z);
            // }
            // if ( mainCam.transform.localPosition.y < Public.instance.Yend1) {
            //      mainCam.transform.localPosition = new Vector3 ( mainCam.transform.localPosition.x, Public.instance.Yend1, mainCam.transform.localPosition.z);
            // }else if (mainCam.transform.localPosition.y > Public.instance.Yend2){
            //      mainCam.transform.localPosition = new Vector3 ( mainCam.transform.localPosition.x,  Public.instance.Yend2 ,mainCam.transform.localPosition.z);

            // }
        }


        // Vector3 pos = mainCam.transform.localPosition;

        // if (gesture.pickedUIElement.name.Length > 3) {
        //  if (gesture.pickedUIElement.name.Substring (0, 3) == "map") {
        //      mainCam.transform.Translate (Vector3.left * gesture.deltaPosition.x / Screen.width * moveSpeed, Space.World);
        //      mainCam.transform.Translate (Vector3.down * gesture.deltaPosition.y / Screen.height * moveSpeed, Space.World);
        //      if (pos.x < -283f) {
        //          mainCam.transform.localPosition = new Vector3 (-283f, pos.y, pos.z);
        //      }
        //      if (pos.x > 1571f) {
        //          mainCam.transform.localPosition = new Vector3 (1571f, pos.y, pos.z);
        //      }
        //      if (pos.y < 850f) {
        //          mainCam.transform.localPosition = new Vector3 (pos.x, 850f, pos.z);
        //      }
        //      if (pos.y > 1899f) {
        //          mainCam.transform.localPosition = new Vector3 (pos.x, 1899f, pos.z);
        //      }
        //  }
        // //}
        // }
    }