void Update() { if (Input.touchCount >= 1 && !isDragSlide) { if ((Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))) { //新的操控模式 if (Input.touchCount > 1) { if (FingerState != FingerTouchState.TwoFingerTouch) { //enter_special_two_finger_state(); FingerState = FingerTouchState.TwoFingerTouch; } touchCtrl.TouchTwoFinger(); } else if (Input.touchCount == 1) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.OneFingerTouch; } touchCtrl.TouchOneFinger(); } } } #if UNITY_STANDALONE_WIN || UNITY_EDITOR else { if (!isDragSlide && !EventSystem.current.IsPointerOverGameObject()) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.NonFingerTouch; } touchCtrl.MouseClick(); touchCtrl.MouseDrag(); touchCtrl.MouseRollWheel(); } } #endif }
private void Update() { //是否处于旋转状态 if (is_360) { //根据旋转时间改变控制参数 Interaction.instance.x += Time.deltaTime * moveSpeed; Interaction.instance.RotateOpera(Interaction.instance.x, Interaction.instance.y); // //根据旋转时间改变控制参数 // x += Time.deltaTime * moveSpeed; // Quaternion rotation = Quaternion.Euler(y, x, z); // emptyBox.transform.rotation = rotation; } #if UNITY_STANDALONE_WIN || UNITY_EDITOR //滑动条缩放 if (disCon) { Camera.main.transform.localPosition = new Vector3(Camera.main.transform.localPosition.x, Camera.main.transform.localPosition.y, distanceControl.minValue + distanceControl.maxValue - distanceControl.value); distance = Camera.main.transform.localPosition.z; } else { if (distanceControl != null) { distanceControl.value = Camera.main.transform.localPosition.z; } } #endif if (Input.GetMouseButton(0) && !disCon) { is_360 = false; isAutoRotation = false; } //Debug.Log(isAutoRotation +"--"+disCon+"--"+ (isWeiKe && PPTGlobal.PPTEnv != PPTGlobal.PPTEnvironment.PPTPlayer && PPTGlobal.pptStatus != PPTGlobal.PPTStatus.pause)); if (isAutoRotation || disCon || (isWeiKe && PPTGlobal.PPTEnv != PPTGlobal.PPTEnvironment.PPTPlayer && PPTGlobal.pptStatus != PPTGlobal.PPTStatus.pause)) { setParamValue(); return; } bool isInModelControlArea = isInUiRect(); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer && (Input.GetMouseButtonDown(0) || Input.touchCount != 0)) { try { if (PPTController.currentSlideObj != null) { PPTController.currentSlideObj.BroadcastMessage("SetModelCam", isInModelControlArea, SendMessageOptions.DontRequireReceiver); } } catch (Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); } } //#if UNITY_ANDROID || UNITY_IPHONE //移动端判断如下 // if (isInModelControlArea && (PublicClass.currentModle == ModleChoose.SignModel || (SceneModels.instance != null && !SceneModels.instance.get_Split_mode())) && ((Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) || isWeiKe)) //#else //PC端判断如下 //if (isInModelControlArea && (PublicClass.currentModle == ModleChoose.SignModel || (SceneModels.instance != null && !SceneModels.instance.get_Split_mode())) && (!EventSystem.current.IsPointerOverGameObject() || isWeiKe)) //#endif if (isInModelControlArea && (PublicClass.currentModle == ModleChoose.SignModel || PublicClass.currentModle == ModleChoose.AniModel || (SceneModels.instance != null && !SceneModels.instance.get_Split_mode()))) { if (XT_AllButton.isPrintMode) { return; } if (Input.touchCount >= 1) { if ((Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) || isWeiKe) { //新的操控模式 if (Input.touchCount > 1) { if (FingerState != FingerTouchState.TwoFingerTouch) { //enter_special_two_finger_state(); FingerState = FingerTouchState.TwoFingerTouch; } touchCtrl.TouchTwoFinger(); } else if (Input.touchCount == 1) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.OneFingerTouch; } touchCtrl.TouchOneFinger(); } } } else { if ((!EventSystem.current.IsPointerOverGameObject() || isWeiKe)) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.NonFingerTouch; } touchCtrl.MouseClick(); touchCtrl.MouseDrag(); touchCtrl.MouseRollWheel(); } } } //性能测试 //if(Input.GetKeyDown(KeyCode.K)) //{ // recordState = new PlayerCommand(); // Debug.Log("记录模型状态"); // SceneModels.instance.SendHideMessage("淋巴"); //} //if(Input.GetKeyDown(KeyCode.B)) //{ // recordState.RevocationCommand(); // Debug.Log("读取模型状态"); //} #region 旧的操控模式(目前已弃用) 鼠标操控 // //清空上一帧的碰撞点位置 // if (!Input.GetMouseButton(1) /*&& Input.touchCount != 2*/) // { // lastTransPos.Clear(); // } // //鼠标右键平移 // if (Input.GetMouseButton(1)) // { // if (lastTransPos.Count == 0) // { // lastTransPos.Add(uicam.ScreenToWorldPoint(Input.mousePosition)); // } // else // { // Vector3 tmp = uicam.ScreenToWorldPoint(Input.mousePosition); // moveCam(lastTransPos[0], tmp); // lastTransPos[0] = tmp; // } // } // //鼠标左键旋转 // if (Input.GetMouseButton(0)) // { // PublicClass.currentState = RunState.Playing; // PublicClass.CurrentFingerState = FingerState.SingleFingerRotate; // //根据触摸点计算X与Y位置 // x += Input.GetAxis("Mouse X") * xSpeed; // y += Input.GetAxis("Mouse Y") * ySpeed; // Quaternion rotation = Quaternion.Euler(y, x, z); // emptyBox.transform.rotation = rotation; // } // //鼠标滚轮缩放 // if (Input.GetAxis("Mouse ScrollWheel") != 0) // { // distance -= Input.GetAxis("Mouse ScrollWheel") * distanceSpeed; // distance = Mathf.Clamp(distance, minDistance, maxDistance); // Vector3 position = new Vector3(transform.localPosition.x, transform.localPosition.y, distance); // transform.localPosition = position; // } // #endregion // #region 触控板操作 //如果有触控点操作 //if (Input.touchCount >= 1) //{ // if (Input.touchCount != 2) // { // lastTransPos.Clear(); // } // //判断触摸数量为单点触摸 // if (Input.touchCount == 1) // { // PublicClass.OpenPreRecordState = true; // //触摸类型为移动触摸时,旋转模型 // if (Input.GetTouch(0).phase == TouchPhase.Moved) // { // DebugLog.DebugLogInfo("单指移动 坐标:" + Input.GetTouch(0).position); // //将当前触摸状态切换为单指旋转 // PublicClass.CurrentFingerState = FingerState.SingleFingerRotate; // XT_AllButton.Instance.SignExplain.SetActive(false); // x += Input.GetTouch(0).deltaPosition.x; // y += Input.GetTouch(0).deltaPosition.y; // DebugLog.DebugLogInfo("旋转轴向参数: x: " + x + " y: " + y); // } // Quaternion rotation_iphone = Quaternion.Euler(y, x, 0); // emptyBox.transform.rotation = rotation_iphone; // } // //判断触摸数量为多点触摸 // else if (Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved) // { // PublicClass.OpenPreRecordState = true; // PublicClass.currentState = RunState.Playing; // //前两只手指触摸类型都为移动触摸 // //计算出当前两点触摸点的位置 // Vector2 tempPosition1 = Input.GetTouch(0).position; // Vector2 tempPosition2 = Input.GetTouch(1).position; // DebugLog.DebugLogInfo("touch_1: " + tempPosition1 + " touch_2 : " + tempPosition2); // float flag = Input.GetTouch(0).deltaPosition.x * Input.GetTouch(1).deltaPosition.x + Input.GetTouch(0).deltaPosition.y * Input.GetTouch(1).deltaPosition.y; // DebugLog.DebugLogInfo(Input.GetTouch(0).deltaPosition.x + " " + Input.GetTouch(1).deltaPosition.x + " " + Input.GetTouch(0).deltaPosition.y + " " + Input.GetTouch(1).deltaPosition.y); // //函数返回真为放大,返回假为缩小 // //双指实现缩放 // if (flag < 0) // { // DebugLog.DebugLogInfo("缩放: flag: " + flag); // if (IsEnlarge(oldPosition1, oldPosition2, tempPosition1, tempPosition2)) // { // if (distance > minDistance) // { // distance -= zoom * distance; // } // } // else // { // if (distance < maxDistance) // { // distance += zoom * distance; // } // } // //备份上一次触摸点的位置,用于对比 // oldPosition1 = tempPosition1; // oldPosition2 = tempPosition2; // distance = Mathf.Clamp(distance, minDistance, maxDistance); // Vector3 position = new Vector3(transform.localPosition.x, transform.localPosition.y, distance); // transform.localPosition = position; // } // if (flag >= 0)//说明方向相同,开启平移模式 // { // // direction = (Input.GetTouch(0).deltaPosition + Input.GetTouch(1).deltaPosition) / 2; //获取手指touch最后一帧移动的xy轴距离 // // Vector3 temp = new Vector3(-direction.x * distance * translation * Screen.width / 1080 * Screen.height / 1920, // // -direction.y * distance * translation * Screen.width / 1080 * Screen.height / 1920, 0); // // transform.Translate(temp, Space.Self); // // DebugLog.DebugLogInfo("每帧移动向量 temp: (" + temp.x + "," + temp.y + ")"); // if (lastTransPos.Count == 0) // { // lastTransPos.Add(uicam.ScreenToWorldPoint((Input.GetTouch(0).position + Input.GetTouch(1).position) / 2)); // } // else // { // Vector3 tmp = uicam.ScreenToWorldPoint((Input.GetTouch(0).position + Input.GetTouch(1).position) / 2); // moveCam(lastTransPos[0], tmp); // lastTransPos[0] = tmp; // } // } // } //} #endregion }
private void Update() { //是否处于旋转状态 if (is_360) { //根据旋转时间改变控制参数 Interaction.instance.x += Time.deltaTime * moveSpeed; Interaction.instance.RotateOpera(Interaction.instance.x, Interaction.instance.y); // //根据旋转时间改变控制参数 // x += Time.deltaTime * moveSpeed; // Quaternion rotation = Quaternion.Euler(y, x, z); // emptyBox.transform.rotation = rotation; } #if UNITY_STANDALONE_WIN || UNITY_EDITOR //滑动条缩放 if (disCon) { Camera.main.transform.localPosition = new Vector3(Camera.main.transform.localPosition.x, Camera.main.transform.localPosition.y, distanceControl.minValue + distanceControl.maxValue - distanceControl.value); distance = Camera.main.transform.localPosition.z; } else { if (distanceControl != null) { distanceControl.value = Camera.main.transform.localPosition.z; } } #endif if (Input.GetMouseButton(0) && !disCon) { is_360 = false; isAutoRotation = false; } bool isInModelControlArea = isInUiRect(); //if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer && (Input.GetMouseButtonDown(0) || Input.touchCount!=0)) { // try { // if (PPTController.currentSlideObj != null) { // PPTController.currentSlideObj.BroadcastMessage("SetModelCam", isInModelControlArea,SendMessageOptions.DontRequireReceiver); // } // } // catch (Exception e) { // Debug.Log(e.Message); // Debug.Log(e.StackTrace); // } //} if (Input.touchCount >= 1) { if ((Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) || isWeiKe) { //新的操控模式 if (Input.touchCount > 1) { if (FingerState != FingerTouchState.TwoFingerTouch) { //enter_special_two_finger_state(); FingerState = FingerTouchState.TwoFingerTouch; } touchCtrl.TouchTwoFinger(); } else if (Input.touchCount == 1) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.OneFingerTouch; } touchCtrl.TouchOneFinger(); } } } else { if ((!EventSystem.current.IsPointerOverGameObject() || isWeiKe)) { if (FingerState == FingerTouchState.TwoFingerTouch) { //leave_special_two_finger_state(); FingerState = FingerTouchState.NonFingerTouch; } touchCtrl.MouseClick(); touchCtrl.MouseDrag(); touchCtrl.MouseRollWheel(); } } }