Пример #1
0
        private void RotateView()
        {
            // Get the fingers we want to use
            var fingers = NewLeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);
            // Get the scaled average movement vector of these fingers
            var drag = NewLeanGesture.GetScaledDelta(fingers);
            // Get base sensitivity
            var sensitivity = GetSensitivity();

            // Adjust pitch
            Pitch += drag.y * PitchSensitivity * sensitivity;

            if (PitchClamp == true)
            {
                Pitch = Mathf.Clamp(Pitch, PitchMin, PitchMax);
            }
            // Adjust yaw
            Yaw -= drag.x * YawSensitivity * sensitivity;
            if (YawClamp == true)
            {
                Yaw = Mathf.Clamp(Yaw, YawMin, YawMax);
            }
            // Rotate to pitch and yaw values
            transform.localRotation        = Quaternion.Euler(Pitch, 0.0f, 0.0f);
            transform.parent.localRotation = Quaternion.Euler(0.0f, Yaw, 0.0f);
        }
Пример #2
0
        public static float GetTwistRadians(List <NewLeanFinger> fingers)
        {
            var center     = NewLeanGesture.GetScreenCenter(fingers);
            var lastCenter = NewLeanGesture.GetLastScreenCenter(fingers);

            return(GetTwistRadians(fingers, center, lastCenter));
        }
Пример #3
0
        protected virtual void LateUpdate()
        {
            // Make sure the camera exists
            if (NewLeanTouch.GetCamera(ref Camera, gameObject) == true)
            {
                // Get the fingers we want to use
                var fingers = NewLeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

                // Reset pinch ratio before checking new pinch ratio
                var pinchRatio = prevZoom;

                // Check position of figures
                for (var i = 0; i < fingers.Count; i++)
                {
                    if (!minimapZoom && !MyCloseUpCamera.GetComponent <Camera>().enabled)
                    {
                        var checkFinger = fingers[i];
                        if (checkFinger.ScreenPosition.x > 740 && checkFinger.ScreenPosition.y < 225)
                        {
                            minimapZoom = true;
                        }
                    }
                }

                // Get script from assesment camera (which is default)
                Zoomer        ZoomerScript        = (Zoomer)AsessmentCamera.GetComponent(typeof(Zoomer));
                CloseUpCamera CloseUpCameraScript = (CloseUpCamera)MyCloseUpCamera.GetComponent(typeof(CloseUpCamera));

                if (minimapZoom)
                {
                    // Get the pinch ratio of these fingers with minimap sensativty
                    pinchRatio = NewLeanGesture.GetPinchRatio(fingers, MiniMapSensitivity);
                    // Get script from mini map camera
                    ZoomerScript = (Zoomer)MiniMapCamera.GetComponent(typeof(Zoomer));
                    // Mini map min and max zoom
                    ZoomMin = 20.0f;
                    ZoomMax = 960.0f;
                    // Reset mini map zoom
                    minimapZoom = false;
                }
                else
                {
                    // Get the pinch ratio of these fingers
                    pinchRatio = NewLeanGesture.GetPinchRatio(fingers, WheelSensitivity);
                    // Assessment camera min and max zoom
                    ZoomMin = 20.0f;
                    ZoomMax = 440.0f;
                }

                // Modify the zoom value
                Zoom *= pinchRatio;

                if (Zoom < ZoomMin)
                {
                    Zoom = ZoomMin;
                }
                else if (Zoom > ZoomMax)
                {
                    Zoom = ZoomMax;
                }

                if (pinchRatio != prevZoom)
                {
                    //Calculate percentage of zoom
                    float ZoomPercent = (Zoom - ZoomMin) / (ZoomMax - ZoomMin);
                    float distanceMin = CloseUpCameraScript.distanceMin;
                    float distanceMax = CloseUpCameraScript.distanceMax;
                    CloseUpCameraScript.distance = Mathf.Clamp((ZoomPercent * (distanceMax - distanceMin) + distanceMin), distanceMin, distanceMax);
                    ZoomerScript.UpdateSSVCameraPosition(Zoom);
                }
                Zoom     = ZoomerScript.getZoomValue();
                prevZoom = pinchRatio;
            }
        }