Ejemplo n.º 1
0
        /// <summary>
        /// Continue tween to the target's position in update.
        /// </summary>
        private void ContinueTween()
        {
            if (!mContinueTween)
            {
                return;
            }

            if (mTargetTransform == null)
            {
#if (UNITY_EDITOR)
                // log string to console cost alost of performance.
                // so do it only when is debug mode.
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogError(
                        "Start the tween but the target transform are null...");
                }
#endif

                mContinueTween = false;
                return;
            }

            float   distance  = 0;
            Vector3 selfVal   = GetSelfTransformTypeVector3();
            Vector3 targetVal = GetTargetTransformTypeVector3();

            // no need to tween again if the position has not change.
            if (mRecordTargetTransformValue == targetVal)
            {
                return;
            }

            DoTween(targetVal, false);

            // Everytime we do tween will make 'mContinueTween' to false,
            // so make sure we enable this back here after do tween.
            mContinueTween = true;

            // record down the target position
            mRecordTargetTransformValue = targetVal;


            // Check if close enough to the distance we target.
            distance = Vector3.Distance(selfVal, targetVal);
            if (distance <= mStopTweenDistance)
            {
                mContinueTween = false;

                // call the call back.
                tweener.ResetTweener();
                tweener.DoCallBack();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Continue tween to the target's position in update.
        /// </summary>
        private void ContinueTween()
        {
            if (!mContinueTween)
            {
                return;
            }

            if (mTargetTransform == null)
            {
                mContinueTween = false;
                return;
            }

            float   distance  = 0;
            Vector3 selfVal   = GetSelfTransformTypeVector3();
            Vector3 targetVal = GetTargetTransformTypeVector3();

            // no need to tween again if the position has not change.
            if (mRecordTargetTransformValue == targetVal)
            {
                return;
            }

            DoTween(targetVal, false);

            // Everytime we do tween will make 'mContinueTween' to false,
            // so make sure we enable this back here after do tween.
            mContinueTween = true;

            // record down the target position
            mRecordTargetTransformValue = targetVal;


            // Check if close enough to the distance we target.
            distance = Vector3.Distance(selfVal, targetVal);
            if (distance <= mStopTweenDistance)
            {
                mContinueTween = false;

                // call the call back.
                tweener.ResetTweener();
                tweener.DoCallBack();
            }
        }