Exemple #1
0
        private void Update()
        {
#if (UNITY_EDITOR)
            Test();
#endif
            if (mTargetTransform == null)
            {
                return;
            }

            InputCamera();

            // update the angle from target we are following
            mTargetAngle = mTargetTransform.localEulerAngles.y;


            DoFollowing();

            DoResetToAxis();

            UpDownMovement();


            // get the wheel value from the Unity API
            // (physical layer[mouse wheel] ->
            // os layer[windows7] ->
            // application layer[Unity itself]) ->
            // to here...
            mWheelDegree = Input.GetAxis("Mouse ScrollWheel");
            ZoomCamera(mWheelDegree);

            // Fix the speed if reach the distance!
            FixedMinMaxDistance();

            Vector3 newPos = Vector3.forward * mTargetScrollSpeed * Time.deltaTime;

            // if is valid, do action.
            if (!JCS_Mathf.IsNaN(newPos))
            {
                // record down the position before calling the
                // translate function
                Vector3 currentPos = this.transform.position;

                // do translate base on the scrolling distance
                // we get from the input buffer.
                this.transform.Translate(newPos);

                // get the updated position!
                Vector3 afterTransPos = this.transform.position;

                // update the track position
                mTrackPosition += afterTransPos - currentPos;
            }

            // asymptotic back to zero
            mTargetScrollSpeed += (0 - mTargetScrollSpeed) / mScrollSpeedFriction * Time.deltaTime;
        }
Exemple #2
0
        protected override void LateUpdate()
        {
#if (UNITY_EDITOR)
            Test();
#endif
            base.LateUpdate();

            if (mTargetTransform == null)
            {
                return;
            }

            InputCamera();

            DoFollowing();

            UpDownMovement();


            this.mRecordPosition = this.transform.position;

            if (mZoomWithMouseOrTouch)
            {
#if (UNITY_EDITOR || UNITY_STANDALONE)
                // Get the wheel value from the Unity API
                //
                // physical layer [mouse wheel] ->
                // OS layer ->
                // application layer [Unity itself] ->
                // to here...
                mWheelDegree = Input.GetAxis("Mouse ScrollWheel");
#elif (UNITY_ANDROID || UNITY_IPHIONE || UNITY_IOS)
                JCS_SlideInput slideInput = JCS_InputManager.instance.GetGlobalSlideInput();
                mWheelDegree = slideInput.TouchDistanceDelta;
#endif
                ZoomCamera(mWheelDegree);
            }

            Vector3 newPos = Vector3.forward * mTargetScrollSpeed * Time.deltaTime;

            // if is valid, do action.
            if (!JCS_Mathf.IsNaN(newPos))
            {
                // record down the position before calling the
                // translate function
                Vector3 currentPos = this.transform.position;

                // do translate base on the scrolling distance
                // we get from the input buffer.
                this.transform.Translate(newPos);

                // get the updated position!
                Vector3 afterTransPos = this.transform.position;

                // update the track position
                mTrackPosition += afterTransPos - currentPos;
            }

            // Fix the speed if reach the distance!
            FixedMinMaxDistance();

            // asymptotic back to zero
            mTargetScrollSpeed += (0.0f - mTargetScrollSpeed) / mScrollSpeedFriction * Time.deltaTime;

            // asymptotic revolution
            {
                float revoDelta = (mTargetRevolution - mCurrentRevolution) / mRotateFriction * Time.deltaTime;

                mCurrentRevolution += revoDelta;

                this.transform.RotateAround(mTargetTransform.position, Vector3.up, revoDelta);
            }
        }