Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the manipulation can be started for the given gesture.
        /// </summary>
        /// <param name="gesture">The current gesture.</param>
        /// <returns>True if the manipulation can be started.</returns>
        protected override bool CanStartManipulationForGesture(PinchGesture gesture)
        {
            if (!IsSelected())
            {
                return(false);
            }

            if (gesture.TargetObject != null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private void OnGestureStarted(PinchGesture gesture)
        {
            if (m_IsManipulating)
            {
                return;
            }

            if (CanStartManipulationForGesture(gesture))
            {
                m_IsManipulating    = true;
                gesture.onUpdated  += OnUpdated;
                gesture.onFinished += OnFinished;
                OnStartManipulation(gesture);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Continues the scaling of the object.
        /// </summary>
        /// <param name="gesture">The current gesture.</param>
        protected override void OnContinueManipulation(PinchGesture gesture)
        {
            m_CurrentScaleRatio +=
                k_Sensitivity * GestureTouchesUtility.PixelsToInches(gesture.GapDelta);

            float currentScale = CurrentScale;

            transform.localScale = new Vector3(currentScale, currentScale, currentScale);

            // If we've tried to scale too far beyond the limit, then cancel the gesture
            // to snap back within the scale range.
            if (m_CurrentScaleRatio < -k_ElasticRatioLimit ||
                m_CurrentScaleRatio > (1.0f + k_ElasticRatioLimit))
            {
                gesture.Cancel();
            }
        }
Ejemplo n.º 4
0
        private void OnUpdated(PinchGesture gesture)
        {
            if (!m_IsManipulating)
            {
                return;
            }

            // Can only transform selected Items.
            if (ManipulationSystem.Instance.SelectedObject != gameObject)
            {
                m_IsManipulating = false;
                OnEndManipulation(gesture);
                return;
            }

            OnContinueManipulation(gesture);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Finishes the scaling of the object.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected override void OnEndManipulation(PinchGesture gesture)
 {
     m_IsScaling = false;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Recalculates the current scale ratio in case local scale, min or max scale were changed.
 /// </summary>
 /// <param name="gesture">The gesture that started this transformation.</param>
 protected override void OnStartManipulation(PinchGesture gesture)
 {
     m_IsScaling         = true;
     m_CurrentScaleRatio = (transform.localScale.x - MinScale) / ScaleDelta;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns true if the manipulation can be started for the given gesture.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 /// <returns>True if the manipulation can be started.</returns>
 protected virtual bool CanStartManipulationForGesture(PinchGesture gesture)
 {
     return(false);
 }
Ejemplo n.º 8
0
 private void OnFinished(PinchGesture gesture)
 {
     m_IsManipulating = false;
     OnEndManipulation(gesture);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Function called when the manipulation is ended.
 /// </summary>
 /// <param name="gesture">The current gesture.</param>
 protected virtual void OnEndManipulation(PinchGesture gesture)
 {
     // Optional override.
 }